Reputation: 1954
I have a dialog as below :
showDialog(
context: context,
barrierDismissible : true,
useRootNavigator: true,
builder: (BuildContext context) {
return new AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(5.0))),
title: new Flex(
direction: Axis.horizontal,
children: <Widget>[
new CircularProgressIndicator(),
new Padding(
padding: EdgeInsets.only(left: 20.0),
child: new Text("Loading...", style: new TextStyle(
fontSize: 14.0,
color: Colors.black54,
fontFamily: "GoogleSans",
fontWeight: FontWeight.w400
), textAlign: TextAlign.left),
)
],
),
);
},
);
and try to dismiss it with function :
Navigator.of(context, rootNavigator: true).pop();
when in the process of developing, the navigator function it runs well and closes the dialog as expected. but when I upload the application in the google play store, and run the application through the google play store, the navigator function actually closes the application instead of closing the dialog. Why did it happen? is there something wrong with my code ?
and this my flutter doctor -v
Flutter (Channel stable, v1.12.13+hotfix.7, on Mac OS X 10.15.3 19D76, locale en-ID)
• Flutter version 1.12.13+hotfix.7 at /Users/macpro/Documents/Development/flutter
• Framework revision 9f5ff2306b (2 weeks ago), 2020-01-26 22:38:26 -0800
• Engine revision a67792536c
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/macpro/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS (Xcode 11.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3.1, Build version 11C504
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install:
sudo gem install cocoapods
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 43.0.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.42.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.8.0
[✓] Connected device (1 available)
• SM J330G • 4200db84cc425415 • android-arm • Android 9 (API 28)
Upvotes: 2
Views: 1964
Reputation: 129
Try changing useRootNavigator: false
, and dismiss your dialog by calling Navigator.of(context).pop()
Upvotes: 1
Reputation: 202
Instead of using Navigator.of(context, rootNavigator: true).pop();
use Navigator.of(context).pop();
This should solve the issue. Using Navigator.of(context, rootNavigator: true).pop();
is only necessary if you have multiple Navigator objects in your application.
Otherwise, rootNavigator: True
need not be declared.
Upvotes: 1