diff --git a/lib/widgets/alert.dart b/lib/widgets/alert.dart index 2012fa3b..bba89abd 100644 --- a/lib/widgets/alert.dart +++ b/lib/widgets/alert.dart @@ -218,6 +218,8 @@ Future showOverlayDialog({ return completer.future; } +const kDialogMaxWidth = 480.0; + void showErrorAlert(dynamic err) { if (err is Error) { talker.error('Something went wrong...', err, err.stackTrace); @@ -231,15 +233,18 @@ void showErrorAlert(dynamic err) { showOverlayDialog( builder: - (context, close) => AlertDialog( - title: Text('somethingWentWrong'.tr()), - content: Text(text), - actions: [ - TextButton( - onPressed: () => close(null), - child: Text(MaterialLocalizations.of(context).okButtonLabel), - ), - ], + (context, close) => ConstrainedBox( + constraints: const BoxConstraints(maxWidth: kDialogMaxWidth), + child: AlertDialog( + title: Text('somethingWentWrong'.tr()), + content: Text(text), + actions: [ + TextButton( + onPressed: () => close(null), + child: Text(MaterialLocalizations.of(context).okButtonLabel), + ), + ], + ), ), ); } @@ -247,15 +252,18 @@ void showErrorAlert(dynamic err) { void showInfoAlert(String message, String title) { showOverlayDialog( builder: - (context, close) => AlertDialog( - title: Text(title), - content: Text(message), - actions: [ - TextButton( - onPressed: () => close(null), - child: Text(MaterialLocalizations.of(context).okButtonLabel), - ), - ], + (context, close) => ConstrainedBox( + constraints: const BoxConstraints(maxWidth: kDialogMaxWidth), + child: AlertDialog( + title: Text(title), + content: Text(message), + actions: [ + TextButton( + onPressed: () => close(null), + child: Text(MaterialLocalizations.of(context).okButtonLabel), + ), + ], + ), ), ); } @@ -263,19 +271,24 @@ void showInfoAlert(String message, String title) { Future showConfirmAlert(String message, String title) async { final result = await showOverlayDialog( builder: - (context, close) => AlertDialog( - title: Text(title), - content: Text(message), - actions: [ - TextButton( - onPressed: () => close(false), - child: Text(MaterialLocalizations.of(context).cancelButtonLabel), - ), - TextButton( - onPressed: () => close(true), - child: Text(MaterialLocalizations.of(context).okButtonLabel), - ), - ], + (context, close) => ConstrainedBox( + constraints: const BoxConstraints(maxWidth: kDialogMaxWidth), + child: AlertDialog( + title: Text(title), + content: Text(message), + actions: [ + TextButton( + onPressed: () => close(false), + child: Text( + MaterialLocalizations.of(context).cancelButtonLabel, + ), + ), + TextButton( + onPressed: () => close(true), + child: Text(MaterialLocalizations.of(context).okButtonLabel), + ), + ], + ), ), ); return result ?? false;