Repository: flutter
Issue: RootBackButtonDispatcher and onPopPage behaves inconsistently for the last page
Labels: platform-android,framework,has reproducible steps,P2,found in release: 3.3,found in release: 3.7,team-android,triaged-android

## Steps to Reproduce

1. Execute `flutter run` on the code sample on the emulator
When there is only one page in Navigator.pages(Line 30)
2. Click "hardware" back button and observe that:
a) `onPopPage` is not being called
b) app is moved to the background
3. uncomment Line 33 and reload - now there are two pages
4. Click "hardware" back button. Second page is being popped as expected. Now there is only one page at stack
5. Click "hardware" back button once again and observe that:
a) `onPopPage` **IS** being called
b) app is **NOT** moved to the background (although it is the "last" page)

**Expected results:**
Last page behaviour is always the same regarding moving to the background or not and calling `onPopPage` or not

**Actual results:**
Behaviour for the last page is different

<details>
<summary>Code sample</summary>

https://dartpad.dev/?id=f34bbf73b9abae0d86bf222d1373ca05

```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>();

  @override
  Widget build(BuildContext context) => Navigator(
      key: navigatorKey,
      pages: const [
        MaterialPage(child: InnerScreen(text: "Inner screen 1",)),
        //Uncomment following line:
        // MaterialPage(child: InnerScreen(text: "Inner screen 2",))
      ],
      onPopPage: (route, result) {
        print('onPopPage: ${DateTime.now()}\n');

        if (!route.didPop(result)) {
          return false;
        }
        return false;
      },
    );

  @override
  Future<void> setNewRoutePath(final AppState configuration) async {
  }
}

class AppState extends ChangeNotifier {
}


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),
          ],
        ),
      ),
    );
  }
}
```

</details>

<details>
  <summary>Logs</summary>

```
no logs
```


```
   info - Avoid `print` calls in production code - lib\main.dart:36:9 - avoid_print
```


```
[√] Flutter (Channel stable, 3.3.4, on Microsoft Windows [Version 10.0.19044.2006], locale pl-PL)
    • Flutter version 3.3.4 on channel stable at C:\Users\User\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision eb6d86ee27 (3 months ago), 2022-10-04 22:31:45 -0700
    • Engine revision c08d7d5efc
    • Dart version 2.18.2
    • DevTools version 2.15.0

[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\Users\User\AppData\Local\Android\sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • 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 2021.3)
    • 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.13+0-b1751.21-8125866)

[√] VS Code (version 1.74.2)
    • VS Code at C:\Users\User\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.56.0

[√] Connected device (3 available)
    • 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.
-->