Skip to content

Navigator.pop call on a AlertDialog pops route twice on V7 #1065

Open

Description

@pedromellofh

Description
When I call Navigator.pop to close a AlertDialog shown after a button click inside a widget reached via context.pushNamed using a route declared in a module, the dialog is closed (expected result) but the route of the underneath widget is popped too, causing the application to leave the widget instead of staying on the widget (the behavior I had on V6).

Environment
flutter.doctor.txt
pubspec.yaml.txt

Activity

  1. PhillDubois commented on Oct 27, 2026

    @PhillDubois

    I'm having the same error here when I show a Dialog using

    static Future<T?> showFullScreenDialog<T extends Object?>({
        required BuildContext context,
        required Widget child,
        bool barrierDismissible = false,
        String barrierLabel = 'Disclaimer',
      }) async {
        return showGeneralDialog<T>(
          context: context,
          barrierDismissible: barrierDismissible,
          barrierLabel: barrierLabel,
          pageBuilder: (context, animation, secondaryAnimation) {
            return PopScope(
              canPop: false,
              child: child,
            );
          },
          transitionBuilder: (context, animation, secondaryAnimation, child) {
            return FadeTransition(
              opacity: animation,
              child: child,
            );
          },
        );
      }

    and inside the widget I do a: context.pop(). It's popping the current route.
    My modular app is setup like that:

    ModularApp(
      module: appModule,
      navigatorKey: navigatorKey,
      child: MaterialApp.router(
        scaffoldMessengerKey:
            SnackBarService.to.scaffoldMessengerKey,
        debugShowCheckedModeBanner: false,
        restorationScopeId: 'app',
        localizationsDelegates:
            context.localizationDelegates,
        supportedLocales: context.supportedLocales,
        locale: context.locale,
        onGenerateTitle: (context) => Env.appName,
        routerConfig: ModularApp.routerConfigOf(
          context,
        ),
      ),
    )

    The workaround I found for now was doing this:

    final navigator = Navigator.of(context, rootNavigator: true);
        navigator.popUntil((route) {
          return route is! PopupRoute;
        });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    newNew issue request attention

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions