Repository: flutter
Issue: [Go Router] Web forward and back button in app using Navigator 1.0 do not work when used inside a package using go_router
Labels: platform-web,has reproducible steps,P2,p: go_router,team-go_router,triaged-go_router,found in release: 3.13,found in release: 3.14

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

### Sample project 

[https://github.com/1q09/go_router_test](https://github.com/1q09/go_router_test)

Video attached for the issue.

Create a package having two screen which uses go router to navigate 

[Example main file](https://github.com/1q09/go_router_test/blob/main/example/lib/main.dart)

```
GlobalKey<NavigatorState> _mfRootNavigatorKey =
    GlobalKey<NavigatorState>(debugLabel: 'gokeys');
final router = GoRouter(
  navigatorKey: _mfRootNavigatorKey,
  initialLocation: '/home',
  debugLogDiagnostics: true,
  routes: [
    GoRoute(
        name: 'home',
        path: '/home',
        builder: (context, state) {
          return const Home();
        },
        routes: [
          GoRoute(
            name: 'detail',
            path: 'detail',
            pageBuilder: (context, state) =>
                const NoTransitionPage(child: Detail()),
          )
        ])
  ],
);
```
In package create entry point

```
class GoTest {
  final GlobalKey<NavigatorState> navigationKey;

  GoTest({required this.navigationKey});

  void launchMyPackageScreen({Map<String, dynamic>? extras}) {
    navigationKeyMF = navigationKey;
    final BuildContext? context = navigationKey.currentContext;
    if (context == null) {
      throw Exception('context can not be null');
    }
    Navigator.of(context).push(MaterialPageRoute<dynamic>(
      builder: (context) => WillPopScope(
          onWillPop: () {
            if (router.canPop()) {
              router.pop();
              return Future.value(true);
            }
            return Future.value(true);
          },
          child: const AppStartPoint()),
    ));
  }
}


class AppStartPoint extends StatefulWidget {
  const AppStartPoint({super.key});

  @override
  State<AppStartPoint> createState() => _AppStartPointState();
}

class _AppStartPointState extends State<AppStartPoint> {
  @override
  void initState() {
    super.initState();
  }

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      routerConfig: router,
      debugShowCheckedModeBanner: false,
      title: 'Neo Mutual Fund',
      builder: (context, Widget? child) {
        return Stack(
          children: [
            child!,
          ],
        );
      },
    );
  }
}

void closeApp() {
  Navigator.pop(navigationKeyMF.currentContext!);
}
```


### Expected results

Web back and forward button should work as expected in a normal website. 
should pop and go to that route displayed in web url

### Actual results

Back and forward button doing nothing.

### Code sample

<details><summary>Code sample</summary>


[Sample code](https://github.com/1q09/go_router_test)


</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

https://github.com/flutter/flutter/assets/102970345/19ab39ca-07fc-4dbf-88c0-1ded676a0c72


</details>


### Logs

<details><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.12, on macOS 13.3.1 22E772610a darwin-arm64, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] Android Studio (version 2022.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.1.2)
[✓] VS Code (version 1.81.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!

```

</details>