From 6102b39e9dedfc4ff2ee7318fcf3a60178d2cde5 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 26 May 2020 23:40:20 +1000 Subject: [PATCH] Improve functionality of showErrorDialog function - Provide callback for when the dialog is dismissed - Optionally set the error title bar --- lib/widget/dialogs.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/widget/dialogs.dart b/lib/widget/dialogs.dart index 57de3a63..a8ce942d 100644 --- a/lib/widget/dialogs.dart +++ b/lib/widget/dialogs.dart @@ -9,12 +9,12 @@ void showMessage(BuildContext context, String message) { )); } -void showErrorDialog(BuildContext context, String title, String description) { +Future showErrorDialog(BuildContext context, String title, String description, {String error = "Error", Function onDismissed}) async { showDialog( context: context, child: SimpleDialog( title: ListTile( - title: Text("Error"), + title: Text(error), leading: FaIcon(FontAwesomeIcons.exclamationCircle), ), children: [ @@ -24,7 +24,11 @@ void showErrorDialog(BuildContext context, String title, String description) { ) ] ) - ); + ).then((value) { + if (onDismissed != null) { + onDismissed(); + } + }); } void showProgressDialog(BuildContext context, String title, String description) {