Skip to content

Package: Go-router - Unexpected behaviour with version 13.0.0 #140888

@LordOlumide

Description

@LordOlumide

When a drawer and a dialog are open at the same time, I think context.pop targets the drawer instead of the dialog.

Steps to reproduce

  1. Add go_router version 13.0.0 to your app.
  2. Create a Scaffold and add a drawer to the scaffold.
  3. In the drawer, add a button that runs a function that shows a Dialog that can be dismissed with context.pop(true) and context.pop(false).
  4. Check the code sample I added below for an example of the function.
  5. If the Dialog calls context.pop(true) or context.pop(false), the drawer closes without dismissing the dialog or completing the rest of the function.
  6. After this, when the dialog calls context.pop(true) or context.pop(false) again, the dialog is dismissed but the rest of the code in the function does not run. otherFunction() is not called.
  7. This behaviour does not happen in version 12.1.3 and other version 12.

Expected results

I expected the dialog to be dismissed and the otherFunction to run.

Actual results

The dialog was not dismissed and the otherFunction was not run.

Code sample

Code sample
  Future<void> onSignOutPressed(BuildContext context) async {
    late final bool? shouldSignOut;

    if (context.mounted) {
      shouldSignOut = await showDialog(
        context: context,
        builder: (context) {
          return YesNoDialog( // calls context.pop(true) or context.pop(false)
            title: 'Log out',
            question: 'Are you sure you want to log out?',
          );
        },
      );
    }
    if (shouldSignOut == null || shouldSignOut == false) return;

    otherFunction(); // contains sign out logic
  }
class YesNoChoiceDialog extends StatelessWidget {
  final String title;
  final String question;

  const YesNoChoiceDialog({super.key, required this.title, required this.question});

  @override
  Widget build(BuildContext context) {
    return Dialog(
      insetPadding: EdgeInsets.symmetric(horizontal: 20.w),
      child: Container(
        padding: EdgeInsets.symmetric(horizontal: 20.w),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Text(
              title,
              style: context.semiBold
                  .withSize(23.sp)
                  .withColor(context.greys.$700),
            ),
            Text(
              question,
              style:
                  context.regular.withSize(19.sp).withColor(context.greys.$700),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                ElevatedButton(
                  onPressed: () => context.pop(false),
                  child: Text('No'),
                ),
                ElevatedButton(
                  onPressed: () => context.pop(true),
                  child: Text('Yes'),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.10.5, on Microsoft Windows [Version 10.0.18363.1556], locale en-US)
    • Flutter version 3.10.5 on channel stable at C:\Flutter_sdk\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 796c8ef792 (7 months ago), 2023-06-13 15:51:02 -0700
    • Engine revision 45f6e00911
    • Dart version 3.0.5
    • DevTools version 2.23.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at C:\Users\LordOlumide\AppData\Local\Android\Sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.3)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.5.33516.290
    • Windows 10 SDK version 10.0.22000.0

[√] Android Studio (version 2022.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)

[√] VS Code (version 1.77.3)
    • VS Code at C:\Users\LordOlumide\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (4 available)
    • Infinix X6831 (mobile) • 099244033W003446 • android-arm64  • Android 13 (API 33)
    • Windows (desktop)      • windows          • windows-x64    • Microsoft Windows [Version 10.0.18363.1556]
    • Chrome (web)           • chrome           • web-javascript • Google Chrome 120.0.6099.130
    • Edge (web)             • edge             • web-javascript • Microsoft Edge 114.0.1823.51

[√] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    r: solvedIssue is closed as solved

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions