Repository: flutter
Issue: Awaited GoRouter "push" does not resolve when pressing browser's back button
Labels: platform-web,package,has reproducible steps,P2,p: go_router,team-go_router,triaged-go_router,found in release: 3.24

### Steps to reproduce

Using the sample code below:

1. Press Hello World! to navigate to SettingsPage.
2. Press browser's back button.

### Expected results

After pressing browser's back button, `await context.push('/settings', ...);` should be resolved.

### Actual results

After pressing browser's back button, `await context.push('/settings', ...);` is NOT resolved.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

void main() {
  GoRouter.optionURLReflectsImperativeAPIs = true;
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      routerConfig: GoRouter(
        initialLocation: '/',
        routes: <RouteBase>[
          GoRoute(
            path: '/',
            builder: (_, __) => const HomePage(),
            routes: [
              // This setup does not work also.
              // GoRoute(
              //   path: 'settings',
              //   builder: (_, state) => SettingsPage(
              //     extra: state.extra as String?,
              //   ),
              // ),
            ],
          ),
          GoRoute(
            path: '/settings',
            builder: (_, state) => SettingsPage(
              extra: state.extra as String?,
            ),
          ),
        ],
      ),
    );
  }
}

//--------------------------------------------------------------------------------------------------
class HomePage extends StatelessWidget {
  const HomePage({
    super.key,
  });

  Future<void> _onGoToSettings(BuildContext context) async {
    print('>>>>> GO TO SETTINGS');

    await context.push(
      '/settings',
      extra: 'from Home',
    );

    print('>>>>> BACK TO HOME');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: TextButton(
          onPressed: () => _onGoToSettings(context),
          child: const Text('Hello World!'),
        ),
      ),
    );
  }
}

//--------------------------------------------------------------------------------------------------
class SettingsPage extends StatelessWidget {
  const SettingsPage({
    this.extra,
    super.key,
  });

  final String? extra;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: Text('Hello $extra'),
      ),
    );
  }
}
```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>


https://github.com/user-attachments/assets/9c56abe8-72b6-479c-962d-30a0b3c86009


</details>


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[!] Flutter (Channel [user-branch], 3.22.3, on macOS 14.6.1 23G93 darwin-arm64, locale en-PH)
    ! Flutter version 3.22.3 on channel [user-branch] at
      /Users/rickimaru/Documents/GitHub/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at
      https://flutter.dev/docs/get-started/install.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
    • Framework revision b0850beeb2 (4 weeks ago), 2024-07-16 21:43:41 -0700
    • Engine revision 235db911ba
    • Dart version 3.4.4
    • DevTools version 2.34.3
    • If those were intentional, you can disregard the above warnings; however it is
      recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/rickimaru/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.15.0

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /Applications/Brave Browser.app/Contents/MacOS/Brave Browser

[✓] Android Studio (version 2023.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.92.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.94.0

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 14.6.1
      23G93 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 14.6.1
      23G93 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Brave Browser
      127.1.68.141
    ! Error: Browsing on the local area network for Rick Krystianne’s iPhone. Ensure the
      device is unlocked and attached with a cable or associated with the same local area
      network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
```

</details>