Repository navigation
Improve error message for type error in maybePop()/pop() #16987
Description
Activity
with recent flutter update
Your Flutter version is already 2 weeks old. Have you tried with a more recent one?
I updated Flutter:
[✓] Flutter (Channel dev, v0.3.5, on Mac OS X 10.13.4 17E199, locale en-PH) • Flutter version 0.3.5 at /Users/macbook/Documents/flutter • Framework revision 7ffcd3d22d (5 days ago), 2018-04-24 14:03:41 -0700 • Engine revision ec611470b5 • Dart version 2.0.0-dev.48.0.flutter-fe606f890b [✓] Android toolchain - develop for Android devices (Android SDK 28.0.0-rc1) • Android SDK at /Users/macbook/Library/Android/sdk • Android NDK at /Users/macbook/Library/Android/sdk/ndk-bundle • Platform android-27, build-tools 28.0.0-rc1 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06) • All Android licenses accepted. [✓] iOS toolchain - develop for iOS devices (Xcode 9.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 9.3, Build version 9E145 • ios-deploy 1.9.2 • CocoaPods version 1.3.1 [✓] Android Studio (version 2.3) • Android Studio at /Applications/Android Studio.app/Contents ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. • Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06) [✓] IntelliJ IDEA Community Edition (version 2017.2.5) • IntelliJ at /Applications/IntelliJ IDEA CE.app • Flutter plugin version 19.1 • Dart plugin version 172.4343.25 [!] VS Code (version 1.17.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Dart Code extension not installed; install from https://marketplace.visualstudio.com/items?itemName=Dart-Code.dart-code [✓] Connected devices (1 available) • Android SDK built for x86 • emulator-5554 • android-x86 • Android 7.0 (API 24) (emulator)But still experiencing the same issue
Just started experiencing this
Still experiencing this issue with Flutter v0.3.5
any inputs on this for later version releases?@artAst in the gallery example it uses a enum for the alert types. I wonder if it's something to do with just passing a string.
enum DialogDemoAction { cancel, discard, disagree, agree, }
Then present
showDemoDialog<DialogDemoAction>( context: context, child: new AlertDialog( content: new Text( _alertWithoutTitleText, style: dialogTextStyle ), actions: <Widget>[ new FlatButton( child: const Text('CANCEL'), onPressed: () { Navigator.pop(context, DialogDemoAction.cancel); } ), new FlatButton( child: const Text('DISCARD'), onPressed: () { Navigator.pop(context, DialogDemoAction.discard); } ) ] ) );
It did solve the issue. I also passed in the String object and it works as well. Thanks
This was not present on previous version of flutter with Dart 1.0
The problem is that you said you were returning a Null (the type argument to showDialog), but then you passed a String.
We should definitely make these error messages clear.
- changed the title
[-]Navigator pop or maybe pop error with recent flutter update[/-][+]Improve error message for type error in maybePop()/pop()[/+]on Jun 12, 2018 - addedc: crashStack traces logged to the consoleStack traces logged to the consoleframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.f: routesNavigator, Router, and related APIs.Navigator, Router, and related APIs.
on Jun 12, 2018 - addeda: error messageError messages from the Flutter frameworkError messages from the Flutter framework
on Nov 11, 2019 - addedP2Important issues not at the top of the work listImportant issues not at the top of the work list
on May 29, 2020 9 remaining items
- addedtriaged-frameworkTriaged by Framework teamTriaged by Framework team
on Jul 8, 2023 Not sure if this is still reproducible, we should check.
- added a commit that references this issue
on May 14, 2026 I have tested the issue and confirmed it still exists. In
await showDialog<Null>(, the return type is set asNull, but aStringis being returned insteadNavigator.maybePop(context, "CANCEL");. This type mismatch is what is causing the error.- added 2 commits that reference this issue
on May 29, 2026 - added a commit that references this issue
on Jun 3, 2026 - added a commit that references this issue
on Jun 26, 2026 This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Jul 14, 2026
Steps to Reproduce
Create a new project and have this pop-up box:
Once the cancel or OK button is clicked, it generates an error
Logs
Flutter Doctor