Repository: flutter
Issue: In nested Navigator 2.0 "maybePop" is behaving differently either called by "hardware" back button or other button
Labels: framework,d: api docs,f: routes,has reproducible steps,P2,found in release: 3.3,found in release: 3.7,team-framework,triaged-framework

Since `AppBar` is calling `maybePop` and "hardware" back button is calling `maybePop` (through `PopNavigatorRouterDelegateMixin`) then one could expect that calling `maybePop` will have the same effect. Unfortunatelly it does not.

## Steps to Reproduce

1. Execute `flutter run` on the code sample in the emulator
2. Click "Go Back" button, and observe that `InnerRouterDelegate#onPopPage` is called as expected and page is being popped as expected.
3. Click "Go Back" for the second time and observe that `InnerRouterDelegate#onPopPage` is not being called and app is not being sent to background
4. Now restart the app and:
5. Click "hardware" back button, and observe that `InnerRouterDelegate#onPopPage` is called as expected and page is being popped as expected.
6. Click "hardware" back button again, and observe that app is being sent to background instead of calling `InnerRouterDelegate#onPopPage`

**Expected results:**
`onPopPage` called in the same `BuildContext` does the same thing.

**Actual results:**
`onPopPage` called in the same `BuildContext` but from different button behaves differently

<details>
<summary>Code sample</summary>


```dart
import 'package:flutter/material.dart';

void main() {
  runApp(MainApp());
}

class MainApp extends StatelessWidget {
  final RouterDelegate<AppState> _routerDelegate = MainRouterDelegate();

  MainApp({super.key});
  @override
  Widget build(BuildContext context) =>
    MaterialApp.router(
      routerDelegate: _routerDelegate,
      backButtonDispatcher: RootBackButtonDispatcher(),
    );
}

class MainRouterDelegate extends RouterDelegate<AppState>
    with ChangeNotifier, PopNavigatorRouterDelegateMixin<AppState> {

  @override
  final GlobalKey<NavigatorState> navigatorKey;
  
  MainRouterDelegate() : navigatorKey = GlobalKey<NavigatorState>();

  final AppState appState = AppState();

  @override
  Widget build(BuildContext context) {
    print("Build MainRouter");
    return Navigator(
      key: navigatorKey,
      pages: [
        MaterialPage(
          child: MainScreen(
            key: const ValueKey("mainScreen"),
            text: "Main Page",
            appState: appState,
          )
        ),
      ],
      
      onPopPage: (route, result) {
        print('MainRouterDelegate#onPopPage');

        if (!route.didPop(result)) {
          return false;
        }

        return true;
      },
    );
  }


  @override
  Future<void> setNewRoutePath(AppState configuration) async {
  }

}

class AppState extends ChangeNotifier {
}

class MainScreen extends StatelessWidget {
  MainScreen({super.key, required this.text, required this.appState}): _innerRouterDelegate = InnerRouterDelegate();

  final String text;
  final AppState appState;
  final RouterDelegate<AppState> _innerRouterDelegate;
  
  @override
  Widget build(BuildContext context) {
    ChildBackButtonDispatcher childBackButtonDispatcher = Router.of(context)
        .backButtonDispatcher!
        .createChildBackButtonDispatcher();

    childBackButtonDispatcher.takePriority();

    return Scaffold(
      body: Builder(
        builder: (context) {
          return Router(
            routerDelegate: _innerRouterDelegate,
            backButtonDispatcher: childBackButtonDispatcher,
          );
        }
      ),
    );
  }
}

class InnerRouterDelegate extends RouterDelegate<AppState>
    with ChangeNotifier, PopNavigatorRouterDelegateMixin<AppState> {

  @override
  final GlobalKey<NavigatorState> navigatorKey;

  InnerRouterDelegate() : navigatorKey = GlobalKey<NavigatorState>();

  @override
  Widget build(BuildContext context) {
    print("InnerRouterDelegate#build");
    return Navigator(
      key: navigatorKey,
      pages: const [
        MaterialPage(child: InnerScreen(key: ValueKey('inner1'), text: "Inner 1")),
        MaterialPage(child: InnerScreen(key: ValueKey('inner2'), text: "Inner 2")),
      ],
      onPopPage: (route, result) {
        print('InnerRouterDelegate#onPopPage');
        print(navigatorKey.currentState!.toDiagnosticsNode());
        
        if (!route.didPop(result)) {
          return false;
        }
      
        return true;
      },
    );
  }

  @override
  Future<void> setNewRoutePath(AppState configuration) async {
  }
}

class InnerScreen extends StatelessWidget {
  const InnerScreen({super.key, required this.text});

  final String text;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: Column(
          children: [
            Text(text),
            ElevatedButton(
              onPressed: () {
                print(Navigator.of(context).toDiagnosticsNode());
                Navigator.maybePop(context);
              }, 
              child: const Text("Go Back")
            )
          ],
        ),
      ),
    );
  }
}
```

</details>

<details>
  <summary>Logs</summary>

```
http://127.0.0.1:9102?uri=http://127.0.0.1:35755/SHaX28FCuPY=/
[+3516 ms] I/flutter (15740): NavigatorState#387b2
[  +59 ms] I/flutter (15740): InnerRouterDelegate#onPopPage
[  +39 ms] I/flutter (15740): NavigatorState#387b2
[+1568 ms] I/flutter (15740): NavigatorState#387b2
[   +1 ms] Restarted application in 4 204ms.
[+2151 ms] I/flutter (15740): Build MainRouter
[+1319 ms] I/flutter (15740): InnerRouterDelegate#build
[+3071 ms] I/flutter (15740): InnerRouterDelegate#onPopPage
[   +8 ms] I/flutter (15740): NavigatorState#44873
[ +241 ms] I/flutter (15740): InnerRouterDelegate#build
[+1262 ms] I/flutter (15740): Build MainRouter
[ +172 ms] I/flutter (15740): InnerRouterDelegate#build
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
   info - Don't invoke 'print' in production code - lib\main.dart:31:5 - avoid_print
   info - Don't invoke 'print' in production code - lib\main.dart:45:9 - avoid_print
   info - Don't invoke 'print' in production code - lib\main.dart:104:5 - avoid_print
   info - Don't invoke 'print' in production code - lib\main.dart:112:9 - avoid_print
   info - Don't invoke 'print' in production code - lib\main.dart:113:9 - avoid_print
   info - Don't invoke 'print' in production code - lib\main.dart:144:17 - avoid_print
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[√] Flutter (Channel master, 3.7.0-24.0.pre.52, on Microsoft Windows [Version 10.0.19044.2006], locale pl-PL)
    • Flutter version 3.7.0-24.0.pre.52 on channel master at C:\Users\User\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 8d60a8c0bb (3 days ago), 2023-01-21 03:44:24 -0500
    • Engine revision 3a444b3665
    • Dart version 3.0.0 (build 3.0.0-150.0.dev)
    • DevTools version 2.20.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0) 
    • Android SDK at C:\Users\User\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java       
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe      

[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2022.1)
    • 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 11.0.15+0-b2043.56-8887301)

[√] VS Code (version 1.74.3)
    • VS Code at C:\Users\User\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.56.0

[√] Connected device (4 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)       • windows       • windows-x64    • Microsoft Windows [Version 10.0.19044.2006]
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 107.0.5304.123
    • Edge (web)              • edge          • web-javascript • Microsoft Edge 107.0.1418.42

[√] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.
```

</details>


<!--
      Consider also attaching screenshots and/or videos to better
      illustrate the issue.

      You can upload them directly on GitHub.
      Beware that video file size is limited to 10MB.
-->