Last active
August 18, 2022 18:04
-
-
Save aslamanver/a2b55eab24379839ea2a3a165f91ecb0 to your computer and use it in GitHub Desktop.
Progress & Message Dialog Flutter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
showProgressDialog(BuildContext context) { | |
showDialog( | |
context: context, | |
barrierDismissible: false, | |
builder: (BuildContext context) { | |
return WillPopScope( | |
onWillPop: () async => false, | |
child: AlertDialog( | |
elevation: 0, | |
backgroundColor: Colors.red.withOpacity(0), | |
content: Row( | |
mainAxisAlignment: MainAxisAlignment.center, | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: const [ | |
CircularProgressIndicator(), | |
SizedBox(width: 20), | |
Text( | |
'One moment...', | |
style: TextStyle( | |
color: Colors.white, | |
), | |
), | |
], | |
), | |
), | |
); | |
}, | |
); | |
} | |
showErrorDialog(BuildContext context, String message) { | |
showDialog( | |
context: context, | |
barrierDismissible: false, | |
barrierColor: Colors.black.withOpacity(1), | |
builder: (BuildContext context) { | |
return WillPopScope( | |
onWillPop: () async => false, | |
child: AlertDialog( | |
title: const Text('Error'), | |
content: Text( | |
message, | |
), | |
actions: [ | |
TextButton( | |
child: const Text("OK"), | |
onPressed: () {}, | |
) | |
], | |
), | |
); | |
}, | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment