ABOUT US PROJECTS RESOURCES CONTACT US
< https://flutteragency.com/>
How to Dismiss Dialog In Flutter ?
Somyarajsinh jadeja
< < <
January 10, 2021 · 3 min read
https://www.facebook.com/sharer/sharer.php?
https://twitter.com/intent/tweet?
https://www.linkedin.com/shareArticle?
u=https://flutteragency.com/how-
url=https://flutteragency.com/how-
mini=true&url=https://flutteragency.com/h
to- to- to-
dismiss-
dismiss-
dismiss-
dialog-
dialog-
dialog-
in- in- in-
flutter/>
flutter/&text=How
flutter/>
to
Dismiss
Dialog
In
Flutter
?>
When a user needs to perform some operation on data from the mobile application.
Users need to get permission that may ask the user to confirm the action. So once the
Enquiry
user is displayed a DialogBox it needs to dismiss after getting confirmation. So in this
article, we will go through How to Dismiss Dialog In Flutter?
Also, go through what is Dismissible Widget in Flutter <
https://flutteragency.com/dismissible-widget/> ?
How to Dismiss Dialog In Flutter?
To Dismiss Dialog user needs to make use of an inbuilt class like showDialog <
https://api.flutter.dev/flutter/material/showDialog.html> .
The dialog route created by this method is pushed to the root navigator.
If the application has multiple Navigator objects.
It may be necessary to call Navigator.of(context, rootNavigator:
true).pop(result) to close the dialog rather just Navigator.pop(context, result).
Conser a code snippet like below:
Enquiry
BuildContext dialogContext;
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
dialogContext = context;
return Dialog(
child: new Row(
mainAxisSize: MainAxisSize.min,
children: [
new CircularProgressIndicator(),
new Text("Loading"),
],
),
);
},
);
await _longOperation();
Navigator.pop(dialogContext);
If you don’t want to return any result after showDialog is closed, you can use it.
Navigator.pop(context);
If you want to pass the result call.
Enquiry
Navigator.pop(context, result);
An example will have a code snippet like the below:
Enquiry
showDialog(
context: context,
builder: (_) {
return AlertDialog(
title: Text('Wanna Exit?'),
actions: [
FlatButton(
onPressed: () => Navigator.pop(context, false), //
passing false
child: Text('No'),
),
FlatButton(
onPressed: () => Navigator.pop(context, true), // p
assing true
child: Text('Yes'),
),
],
);
}).then((exit) {
if (exit == null) return;
if (exit) {
// user pressed Yes button
} else {
// user pressed No button
});
The below code will close AlertBox/DialogBox in Flutter. Enquiry
Navigator.of(context).pop();
Conclusion:
In this article, We have been through How to Dismiss Dialog In Flutter?
Keep Learning !!! Keep Fluttering !!!
Do check the article on Dismissible Widget. <
https://flutteragency.com/dismissible-widget/>
Still, need Support for Flutter Development? Do let us know.
FlutterAgency.com < https://flutteragency.com/> is our portal Platform
dedicated to Flutter Technology and Flutter Developers. The portal is full of cool
resources from Flutter like Flutter Widget Guide, Flutter Projects, Code
libs and etc.
FlutterAgency.com < https://flutteragency.com/> is one of the most popular
online portals dedicated to Flutter Technology and daily thousands of unique
visitors come to this portal to enhance their knowledge of Flutter.
Share this:
< https://flutteragency.com/how-to-dismiss-dialog-in-flutter/?share=twitter&nb=1>
< https://flutteragency.com/how-to-dismiss-dialog-in-flutter/?share=facebook&nb=1>
< https://flutteragency.com/how-to-dismiss-dialog-in-flutter/?share=linkedin&nb=1>
Enquiry
< https://flutteragency.com/how-to-dismiss-dialog-in-flutter/?share=reddit&nb=1>
< https://flutteragency.com/how-to-dismiss-dialog-in-flutter/?share=tumblr&nb=1>
< https://flutteragency.com/how-to-dismiss-dialog-in-flutter/?share=jetpack-whatsapp&nb=1>
Popular Posts
How to SetUp Emulator How to Format DateTime How to Fix Android
Abhishek Dhanani posted in
General Somyarajsinh jadeja posted in
General Steve Frazier posted in
General
For VSCode ?
In Flutter ?
License Status Unknown
< https://flutteragency.com/setup-emulator-for-vscode/> In Flutter?
< https://flutteragency.com/how-to-format-datetime-in-flutter/>
November 24, 2020 · 5 min read January 14, 2021 · 3 min read
< https://flutteragency.com/fix-android-license-sta
October 23, 2020 · 6 min read
How to Position Stack How to Call Method in How to Change
Somyarajsinh jadeja posted in
General Somyarajsinh jadeja posted in
General Mahesh Lalwani posted in
General
Widget in Center in Flutter?
One Stateful Widget StatusBar Color in Flutter?
From Another Stateful
< https://flutteragency.com/position-stack-widget-in-center/> < https://flutteragency.com/change-statusbar-colo
October 9, 2020 · 4 min read
Widget In Flutter ??
October 14, 2020 · 3 min read
< https://flutteragency.com/how-to-call-method-in-one-stateful-widget-from-another-statef
December 16, 2020 · 5 min read
Resources Quick Links Help
General < Our Services < About us <
As a customer-focused company, we create solutions for https://flutteragency.com/category/general/>
https://flutteragency.com/our-
https://flutteragency.com/about-
you that incorporate attracting more customers and services/> us/>
Flutter Widget Guide <
converting them. We build simple strategies that not only
https://flutteragency.com/category/flutter-
FAQs < Contact Us <
help brands make an impact but actually help them make
widget-guide/> https://flutteragency.com/faqs/>
https://flutteragency.com/contact-
Enquiry
more money.
us/>
Simple but thorough, we follow a unique, proven approach Apps < Projects < Hire Expert
to ensure that all of our projects are of the highest quality. https://flutteragency.com/category/apps/>
https://flutteragency.com/projects/>
Developers <
https://flutteragency.com/hire-
Github < Hire Flutter Developer
flutter-app-
https://flutteragency.com/category/github/>
<
developer/>
https://flutteragency.com/hire-
Design <
flutter-app-
https://flutteragency.com/category/design/>
developer/>
Privacy Policy <
https://flutteragency.com/privacy-
policy/>
Copyright ©
2021 All right reserved to
Flutter Agency < https://flutteragency.com/> < < <
https://www.facebook.com
https://twitter.com/A
https://www.lin
agency/>
Enquiry