Repository: flutter
Issue: [go_router] Deep Linking Behavior Conflicts with `StatefulShellRoute` in a Custom Navigation Strategies
Labels: package,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

Our existing GoRouter configuration is structured as follows:

```dart
GoRouter(
  routes: [
    ...AllRoutes, // Includes around 50 routes.
    StatefulNavigationRoute(),
  ],
)
```

We have established the following navigation requirements:

- Global pages must be pushed on top of the existing navigation branches (not to replace them).
- Standard pages should be inserted within the currently active branch.
- Authentication and splash pages are expected to replace the entire current stack.

To meet these criteria, we took the following steps:

- For global pages, we used a consistent root navigator key across routes, effectively making them global.
- For standard routes, we used context.push(), which integrates seamlessly with StatefulShellRoute to push pages onto the active branch.
- To replace the current route, we utilized context.go().
- For routes accessed via deep links while on the Auth/Splash screens, we temporarily store them in a DeepLinkRepo. We later navigate to these stored routes using context.push() once we reach the Home Screen.


### Expected results

When deep links are accessed while already on the Home Screen, we expect the navigation to respect both global and standard pages without requiring any additional action on our part.

### Actual results

The deep links behavior appears to use context.go() in the background. This disregards the current navigation stack and pushes the incoming route as if it's the sole page in the application.

### Code sample

<details><summary>Code sample</summary>

```dart
  static Future<String?> _topLevelRedirect(
    BuildContext context,
    GoRouterState state,
  ) async {
    if (!context.authCubit.state.isSuccess) {
      context.dynamicLinkRepo.lastSavedRouterState = state;
    }

    if (state.currentRoute.isNonRedirectableRoute) return null;
 
    ... other simple redirection logic.
    return null;
  }

// from DynamicLinkRepo class
  Future<void> allowNavigation(BuildContext context) async {
    this.context = context;
    if (_lastSavedLocation != null) {
      // the below code actually work as expected since we are using context.push to handle 
      await context.push(_lastSavedLocation!.location);
    }
  }
```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.13.2, on macOS 13.5.1 22G90 darwin-arm64, locale
    en-US)
    • Flutter version 3.13.2 on channel stable at
      /Users/omarkhaled/Development/SDKs/FlutterSDK
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ff5b5b5fa6 (2 weeks ago), 2023-08-24 08:12:28 -0500
    • Engine revision b20183e040
    • Dart version 3.1.0
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/omarkhaled/Development/SDKs/AndroidSDK
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Users/omarkhaled/Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /Applications/Microsoft
      Edge.app/Contents/MacOS/Microsoft Edge

[✓] Android Studio (version 2022.3)
    • Android Studio at /Users/omarkhaled/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.6+0-17.0.6b829.9-10027231)

[✓] IntelliJ IDEA Community Edition (version 2023.2.1)
    • IntelliJ at /Users/omarkhaled/Applications/IntelliJ IDEA Community
      Edition.app
    • Flutter plugin version 75.1.4
    • Dart plugin version 232.9559.10

[✓] VS Code (version 1.81.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.70.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.5.1 22G90
      darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Microsoft Edge 116.0.1938.76

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>