Repository: flutter
Issue: Navigator 2.0 behaves inconsistently
Labels: framework,f: routes,has reproducible steps,P2,found in release: 3.3,found in release: 3.7,team-framework,triaged-framework

## Steps to Reproduce

1. Execute `flutter run .\lib\main.dart` on the code sample
2. Observe, that console displays:
```
Restarted application in 119ms.
#parseRouteInformation. Location is: / -----> Returning configuration with home=null
#currentConfiguration. Home is: false -----> Returning not yet initialized configuration (where home=false)
#restoreRouteInformation. Home is: false -----> Restoring route with incorrect configuration taken from not yet initialized "#currentConfiguration" (with home=false)
AppRouterDelegate#build
#setNewRoutePath. Home is: null -----> Now somehow configuration is the one from #parseRouteInformation method
#currentConfiguration. Home is: null -----> and the flow continues normally
#restoreRouteInformation. Home is: null
AppRouterDelegate#build
```
3. Now navigate to browser's url, type `false` after `/` (so the URL is `http://localhost:32008/#/false`) and hit enter
4. Delete `false` (so the URL again is `http://localhost:32008/#/`) and hit enter
5. Observe console:
```
#parseRouteInformation. Location is: / -----> Returning configuration with home=null
#setNewRoutePath. Home is: null -----> Setting correct configuration from #parse (with home=null)
#currentConfiguration. Home is: null -----> Obtaining correct configuration from #setNewRoutePath (with home=null)
#restoreRouteInformation. Home is: null -----> Restoring route with correct configuration taken from #currentConfiguration (with home=null)
AppRouterDelegate#build
```

**Expected results:**
When application starts, Navigatior should follow the same flow when one enters URL (that is `parseRouteInformation` -> `setNewRoutePath` -> `currentConfiguration` -> `restoreRouteInformation`

**Actual results:**
Navigator for the first time runs `currentConfiguration` before `setNewRoutePath`

<details>
<summary>Code sample</summary>
https://dartpad.dev/?id=9aabf8a89176c67567b32f456bcc5f4c

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp(),);
}

class MyApp extends StatelessWidget {
  MyApp({super.key}) : _routerDelegate = AppRouterDelegate();
  final RouterDelegate<AppState> _routerDelegate;

  @override
  Widget build(BuildContext context) => 
    MaterialApp.router(
      title: 'Test',
      routerDelegate: _routerDelegate,
      routeInformationParser: AppRouteInformationParser(),
      backButtonDispatcher: RootBackButtonDispatcher(),
    );
}

class AppRouteInformationParser extends RouteInformationParser<AppState> {

  @override
  Future<AppState> parseRouteInformation(RouteInformation routeInformation) {
    print("#parseRouteInformation. Location is: ${routeInformation.location}");
    final AppState configuration = AppState();
    if(routeInformation.location == '/') {
      configuration.home = null;
    } else if(routeInformation.location == '/true') {
      configuration.home = true;
    } else {
      configuration.home = false;
    }
    return Future.value(configuration);
  }

  @override 
  RouteInformation? restoreRouteInformation(AppState configuration) {
    print("#restoreRouteInformation. Home is: ${configuration.home}");
    return RouteInformation(
      location: configuration.home == null ? "/" : "/${configuration.home}",
    );
  }
}

class AppRouterDelegate extends RouterDelegate<AppState> with ChangeNotifier, PopNavigatorRouterDelegateMixin<AppState> {

  @override
  final GlobalKey<NavigatorState> navigatorKey;

  AppRouterDelegate() : navigatorKey = GlobalKey<NavigatorState>();

  @override
  Widget build(final BuildContext context) {
    print("AppRouterDelegate#build");
    return Navigator(
      key: navigatorKey,
       pages: [
          const MaterialPage(child: SomePage("Empty")),
          if(_configuration.home ?? false) 
            const MaterialPage(child: SomePage("Home")),
        ],
      onPopPage: (route, result) {
        if (!route.didPop(result)) {
          return false;
        }
        return true;
      },
    );
  }

  AppState _configuration = AppState();
  @override
  AppState get currentConfiguration {
    print("#currentConfiguration. Home is: ${_configuration.home}");
    return _configuration;
  }

  @override
  Future<void> setNewRoutePath(final AppState configuration) async {
    print("#setNewRoutePath. Home is: ${configuration.home}");
    _configuration = configuration;
  }
}

class SomePage extends StatelessWidget {
  const SomePage(this.text, {super.key});
  final String text;
  @override
  Widget build(BuildContext context) {
    return Text(text);
  }
}
class AppState extends ChangeNotifier {
  bool? home = false;
}
```
</details>

<details>
  <summary>Logs</summary>

```
[   +7 ms] Debug service listening on ws://127.0.0.1:31428/yZWqzamUPKA=/ws
[   +1 ms]  Running with sound null safety 
[   +5 ms]   To hot restart changes while running, press "r" or "R".
[   +1 ms] For a more detailed help message, press "h". To quit, press "q".
[   +2 ms] An Observatory debugger and profiler on Chrome is available at: http://127.0.0.1:31428/yZWqzamUPKA=
[  +22 ms] Flutter Web Bootstrap: Auto
[+1476 ms] WARNING: found an existing <meta name="viewport"> tag. Flutter Web uses its own viewport configuration for better compatibility with Flutter. This
tag will be
                    replaced.
[ +202 ms] #parseRouteInformation. Location is: /
[   +3 ms] #currentConfiguration. Home is: false
[   +1 ms] #restoreRouteInformation. Home is: false
[   +1 ms] AppRouterDelegate#build
[  +75 ms] #setNewRoutePath. Home is: null
[   +8 ms] #currentConfiguration. Home is: null
[   +1 ms] #restoreRouteInformation. Home is: null
[   +9 ms] AppRouterDelegate#build
[ +194 ms] The Flutter DevTools debugger and profiler on Chrome is available at: http://127.0.0.1:9102?uri=http://127.0.0.1:31428/yZWqzamUPKA=

[+15125 ms] #parseRouteInformation. Location is: /false
[   +2 ms] #setNewRoutePath. Home is: false
[        ] #currentConfiguration. Home is: false
[   +1 ms] #restoreRouteInformation. Home is: false
[   +3 ms] AppRouterDelegate#build
[+14783 ms] #parseRouteInformation. Location is: /
[   +2 ms] #setNewRoutePath. Home is: null
[   +1 ms] #currentConfiguration. Home is: null
[   +1 ms] #restoreRouteInformation. Home is: null
[   +1 ms] AppRouterDelegate#build
```

```
   info - Avoid `print` calls in production code - lib\main.dart:25:5 - avoid_print
   info - Avoid `print` calls in production code - lib\main.dart:39:5 - avoid_print
   info - Avoid `print` calls in production code - lib\main.dart:55:5 - avoid_print
   info - Avoid `print` calls in production code - lib\main.dart:75:5 - avoid_print
   info - Avoid `print` calls in production code - lib\main.dart:81:5 - 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>