From 9e6fc9825149913afa374188bbebe7dfef9db90b Mon Sep 17 00:00:00 2001 From: Brynly Mitchell - u7088495 Date: Fri, 25 Oct 2024 12:37:22 +1100 Subject: [PATCH] dialog [nfc]: inline _materialDialogActionTest in _adaptiveAction --- lib/widgets/dialog.dart | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/lib/widgets/dialog.dart b/lib/widgets/dialog.dart index 23376ec928..814009ce77 100644 --- a/lib/widgets/dialog.dart +++ b/lib/widgets/dialog.dart @@ -3,20 +3,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/zulip_localizations.dart'; import 'package:flutter/foundation.dart'; -Widget _materialDialogActionText(String text) { - return Text( - text, - - // As suggested by - // https://api.flutter.dev/flutter/material/AlertDialog/actions.html : - // > It is recommended to set the Text.textAlign to TextAlign.end - // > for the Text within the TextButton, so that buttons whose - // > labels wrap to an extra line align with the overall - // > OverflowBar's alignment within the dialog. - textAlign: TextAlign.end, - ); -} - /// A platform-appropriate action for [AlertDialog.adaptive]'s [actions] param. Widget _adaptiveAction({required VoidCallback onPressed, required String text}) { switch (defaultTargetPlatform) { @@ -24,7 +10,13 @@ Widget _adaptiveAction({required VoidCallback onPressed, required String text}) case TargetPlatform.fuchsia: case TargetPlatform.linux: case TargetPlatform.windows: - return TextButton(onPressed: onPressed, child: _materialDialogActionText(text)); + // As suggested by + // https://api.flutter.dev/flutter/material/AlertDialog/actions.html : + // > It is recommended to set the Text.textAlign to TextAlign.end + // > for the Text within the TextButton, so that buttons whose + // > labels wrap to an extra line align with the overall + // > OverflowBar's alignment within the dialog. + return TextButton(onPressed: onPressed, child: Text(text, textAlign: TextAlign.end)); case TargetPlatform.iOS: case TargetPlatform.macOS: return CupertinoDialogAction(onPressed: onPressed, child: Text(text));