Skip to content

Instantly share code, notes, and snippets.

@aslamanver
Last active August 18, 2022 18:04
Show Gist options
  • Save aslamanver/a2b55eab24379839ea2a3a165f91ecb0 to your computer and use it in GitHub Desktop.
Save aslamanver/a2b55eab24379839ea2a3a165f91ecb0 to your computer and use it in GitHub Desktop.
Progress & Message Dialog Flutter
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