Repository: flutter
Issue: [go_router_builder] Embedding a TypedStatefulShellRoute inside another does not preserve the route states.
Labels: package,has reproducible steps,P2,p: go_router_builder,team-go_router,triaged-go_router,found in release: 3.24,found in release: 3.27

### What package does this bug report belong to?

go_router_builder

### What target platforms are you seeing this bug on?

Android, iOS

### Have you already upgraded your packages?

Yes

### Dependency versions

<details><summary>pubspec.lock</summary>

```lock
[Paste file content here]
```

</details>


### Steps to reproduce

Follow the next code snippet to generate some nested routes

```dart

@TypedStatefulShellRoute<AdminShellRoute>(
  branches: [
    /// Parent TypedStatefulShellRoute
    TypedStatefulShellBranch(
      routes: [
        TypedGoRoute<HomeRoute>(
          path: HomeRoute.path,
        ),
      ],
    ),
    TypedStatefulShellBranch(
      routes: [
        // Nested TypedStatefulShellRoute
        TypedStatefulShellRoute<TablesNestedShellRoute>(
          branches: [
            TypedStatefulShellBranch(
              routes: [
                TypedGoRoute<MembersRoute>(
                  path: MembersRoute.path,
                ),
                TypedGoRoute<PaymentsRoute>(
                  path: PaymentsRoute.path,
                ),
                TypedGoRoute<ExpensesRoute>(
                  path: ExpensesRoute.path,
                ),
                TypedGoRoute<BankTransfersRoute>(
                  path: BankTransfersRoute.path,
                ),
              ],
            ),
          ],
        ),
      ],
    ),
    TypedStatefulShellBranch(
      routes: [
        TypedGoRoute<ElectronicInvoicingRoute>(
          path: ElectronicInvoicingRoute.path,
        ),
      ],
    ),
    TypedStatefulShellBranch(
      routes: [
        TypedGoRoute<NotesRoute>(
          path: NotesRoute.path,
        ),
      ],
    ),
    TypedStatefulShellBranch(
      routes: [
        TypedGoRoute<VirtualTrainerRoute>(
          path: VirtualTrainerRoute.path,
        ),
      ],
    ),
  ],
)
```


Now I have a StatelessWidget that I use as the nested tables content with buttons to navigate to MembersRoute, PaymentsRoute , ExpensesRoute and BankTransfersRoute
```dart

class NestedTablesContainer extends StatelessWidget {
  const NestedTablesContainer({super.key, required this.state, required this.navigationShell});
  final GoRouterState state;

  /// The navigation shell and container for the branch Navigators.
  final StatefulNavigationShell navigationShell;

  @override
  Widget build(BuildContext context) {

    final items = <_Tab>[
      (
        path: MembersRoute.path,
        text: 'Miembros',
      ),
      (
        path: PaymentsRoute.path,
        text: 'Pagos',
      ),
      (
        path: ExpensesRoute.path,
        text: 'Gastos',
      ),
      (
        path: BankTransfersRoute.path,
        text: 'Transferencias Bancarias',
      ),
    ];

    final path = state.uri.path;

    return Padding(
      padding: const EdgeInsets.symmetric(horizontal: 10),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            
                  children: List.generate(
                    items.length,
                    (index) {
                      final item = items[index];
                      final active = path.startsWith(item.path);
                      return TabButton(
                        onTap: ()=> context.go(item.path),
                        item:item, active: active,
                       );
                    },
                  ),
                ),
          Expanded(
            child: navigationShell,
          ),
        ],
      ),
    );
  }
}

```






### Expected results

In the nested TypedStatefulShellRoute the state of each route must be maintained.



### Actual results

As you can see the Side Bar menu keep the nested routes state but the tab bar route does not keep the state of its nested routes.



### Code sample

<details open><summary>Code sample</summary>

```dart
[Paste your code here]
```

</details>


### Screenshots or Videos

<details open>
<summary>Screenshots / Video demonstration</summary>

https://github.com/user-attachments/assets/ebe7429f-9498-432b-b13f-90a36041e45c

</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 stable, 3.24.1, on macOS 15.0.1 24A348 darwin-arm64, locale es-EC)
    • Flutter version 3.24.1 on channel stable at /Users/darwin/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5874a72aa4 (9 weeks ago), 2024-08-20 16:46:00 -0500
    • Engine revision c9b9d5780d
    • Dart version 3.5.1
    • DevTools version 2.37.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/darwin/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-11609105)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16A242d
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • 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-11609105)

[✓] VS Code (version 1.94.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.98.0

[✓] Connected device (5 available)
    • iPhone 14 pro max de Darwin (mobile) • 00008120-00064DA92633401E            • ios            • iOS 18.0.1 22A3370
    • iPad Air 11-inch (M2) (mobile)       • 6D883E13-F8DC-4262-8BAC-25A15B05F13B • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator)
    • macOS (desktop)                      • macos                                • darwin-arm64   • macOS 15.0.1 24A348
      darwin-arm64
    • Mac Designed for iPad (desktop)      • mac-designed-for-ipad                • darwin         • macOS 15.0.1 24A348
      darwin-arm64
    • Chrome (web)                         • chrome                               • web-javascript • Google Chrome
      129.0.6668.101

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>