Skip to content

[go_router] GoRouterState incorrect for ShellRoute on .push and .pop #125752

Description

@dalenjohnson

Is there an existing issue for this?

Steps to reproduce

  1. Run sample code.
  2. Press Go /a
  3. Press pop
  4. Press Push /a
  5. Press pop
  6. Check console log print statements

Expected results

Expect context.go(), context.push(), context.pop(), to update GoRouterState in a ShellRoute correctly.

Currently it looks like:
context.go() updates GoRouterState.
context.pop() from a context.go() partially updates GoRouterState(seems to only update .location).
context.push() does NOT update GoRouterState.
context.pop() from a context.push() does NOT update GoRouterState.

A correct GoRouterState in a shell route builder is especially important if you want to display an AppBar in the shell route builder that uses GoRouterState to update the AppBar title or dynamically show a navigation drawer or back button. (Like I show in the sample code)

Another use case would be to grab a param from the GoRouterState to load some logic or state in the shell route builder widget and pass it to a state management solution like Bloc, Inherited Widget or Riverpod ProviderScope to make it available to all child widgets.

I tested this on iOS and Android.
I do not have much experience using queryParams or extra so I did not check if they are updated correctly in GoRouterState during my testing.
Also GoRouterState.name always shows up at null in shell routes and I believe from previous discussions on here that is expected behavior as ShellRoutes don’t have a name parameter. I think that is understandable but I would expect the ShellRoute’s GoRouterState location, subloc, fullPath, params to be updated correctly and with all the params available from the current path.

Actual results

  1. Press Go /a -> GoRouterState updates correctly
  2. Press pop -> GoRouterState.location is correct (subloc, fullpath, params are incorrect)
  3. Press Push /a -> GoRouterState not updated and matches previous state (location, subloc, fullpath, params are incorrect)
  4. Press pop -> GoRouterState not updated and matches previous state

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

void main() {
  runApp(MyApp());
}

final shellKey = GlobalKey<NavigatorState>();

class MyApp extends StatelessWidget {
  MyApp({Key? key}) : super(key: key);

  final _router = GoRouter(
    initialLocation: '/',
    debugLogDiagnostics: true,
    routes: [
      ShellRoute(
        navigatorKey: shellKey,
        builder: (context, state, child) => ShellScaffold(child: child),
        pageBuilder: (context, state, child) =>
            MaterialPage(child: ShellScaffold(child: child)),
        routes: [
          GoRoute(
            name: 'Home',
            path: '/',
            builder: (context, state) => const Home(),
            routes: [
              GoRoute(
                name: 'Page A',
                path: 'a',
                builder: (context, state) => const PageA(),
                routes: [
                  GoRoute(
                    name: 'Page B',
                    path: 'b',
                    builder: (context, state) => const PageB(),
                    routes: [
                      GoRoute(
                        name: 'Page C',
                        path: ':id',
                        builder: (context, state) => PageCWithParam(
                          id: state.params['id']!,
                        ),
                      ),
                    ],
                  ),
                ],
              ),
            ],
          ),
        ],
      )
    ],
  );

  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      title: 'Shell Route State Test',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      routerConfig: _router,
    );
  }
}


class ShellScaffold extends StatelessWidget {
  const ShellScaffold({Key? key, required this.child}) : super(key: key);
  final Widget child;

  @override
  Widget build(BuildContext context) {
    final state = GoRouterState.of(context);
    print('ShellScaffold build');
    print('GoRouter location: ${GoRouter.of(context).location}');
    print('GoRouterState location: ${state.location}');
    print('GoRouterState subloc: ${state.subloc}');
    print('GoRouterState fullpath: ${state.fullpath}');
    print('GoRouterState params: ${state.params}');
    return Scaffold(
      appBar: AppBar(
        title: Text(state.location),
        // automaticallyImplyLeading: true,
        /// automaticallyImplyLeading does not seem work inside of a ShellRoute.
        /// Manually defining leading below is then required to show a back button.
        /// This is why having a correct GoRouterState is needed.
        leading: (state.location.startsWith('/a'))
            ? BackButton(
                onPressed: () => context.pop(),
              )
            : null,
        actions: [
          /// Used to reset the state of the current path and return to home.
          IconButton(
              onPressed: () => context.go('/'), icon: const Icon(Icons.home))
        ],
      ),
      body: child,
    );
  }
}

class Home extends StatelessWidget {
  const Home({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          children: [
            const Text('Home'),
            TextButton(
              onPressed: () => context.go('/a'),
              child: const Text('Go /a'),
            ),
            TextButton(
              onPressed: () => context.push('/a'),
              child: const Text('Push /a'),
            ),
          ],
        ),
      ),
    );
  }
}

class PageA extends StatelessWidget {
  const PageA({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          children: [
            const Text('Page A'),
            TextButton(
              onPressed: () => context.go('/a/b'),
              child: const Text('Go /a/b'),
            ),
            TextButton(
              onPressed: () => context.push('/a/b'),
              child: const Text('Push /a/b'),
            ),
            TextButton(
              onPressed: () => context.pop(),
              child: const Text('pop'),
            ),
          ],
        ),
      ),
    );
  }
}

class PageB extends StatelessWidget {
  const PageB({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        children: [
          const Text('Page B'),
          TextButton(
            onPressed: () => context.go('/a/b/1'),
            child: const Text('Go /a/b/1'),
          ),
          TextButton(
            onPressed: () => context.push('/a/b/2'),
            child: const Text('Push /a/b/2'),
          ),
          TextButton(
            onPressed: () => context.pop(),
            child: const Text('pop'),
          ),
        ],
      ),
    );
  }
}

class PageCWithParam extends StatelessWidget {
  const PageCWithParam({Key? key, required this.id}) : super(key: key);
  final String id;
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        children: [
          Text('Page C with param: $id'),
          TextButton(
            onPressed: () => context.pop(),
            child: const Text('pop'),
          ),
        ],
      ),
    );
  }
}

Flutter Doctor output

Doctor output
[✓] Flutter (Channel beta, 3.10.0-1.1.pre, on macOS 13.3.1 22E261 darwin-arm64, locale en-US)
    • Flutter version 3.10.0-1.1.pre on channel beta at /Users/dalenjohnson/Developer/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ecdb7841df (3 weeks ago), 2023-04-11 20:47:40 -0700
    • Engine revision 870e640e7e
    • Dart version 3.0.0 (build 3.0.0-417.1.beta)
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/dalenjohnson/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.12.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.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 11.0.15+0-b2043.56-8887301)

[✓] VS Code (version 1.77.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.62.0

[✓] Connected device (4 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554                        • android-arm64  • Android 13 (API 33) (emulator)
    • iPhone 14 Pro Max (mobile)  • 9B35DE3E-8844-43EA-ABC2-D440C9A957EE • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    • macOS (desktop)             • macos                                • darwin-arm64   • macOS 13.3.1 22E261 darwin-arm64
    • Chrome (web)                • chrome                               • web-javascript • Google Chrome 112.0.5615.137

[✓] Network resources
    • All expected network resources are available.

• No issues found!]

Activity

  1. darshankawar commented on May 2, 2023

    @darshankawar
    Member

    Thanks for the report. Seeing the same behavior as reported.

    stable, master flutter doctor -v
    [!] Flutter (Channel stable, 3.7.12, on macOS 12.2.1 21D62 darwin-x64, locale
        en-GB)
        • Flutter version 3.7.12 on channel stable at
          /Users/dhs/documents/fluttersdk/flutter
        ! Warning: `flutter` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
          your current Flutter SDK checkout at
          /Users/dhs/documents/fluttersdk/flutter. Consider adding
          /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
          Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
          of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 4d9e56e694 (3 days ago), 2023-04-17 21:47:46 -0400
        • Engine revision 1a65d409c7
        • Dart version 2.19.6
        • DevTools version 2.20.1
        • If those were intentional, you can disregard the above warnings; however
          it is recommended to use "git" directly to perform update checks and
          upgrades.
    
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    [!] Flutter (Channel master, 3.10.0-16.0.pre.23, on macOS 12.2.1 21D62
        darwin-x64, locale en-GB)
        • Flutter version 3.10.0-16.0.pre.23 on channel master at
          /Users/dhs/documents/fluttersdk/flutter
        ! Warning: `flutter` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside
          your current Flutter SDK checkout at
          /Users/dhs/documents/fluttersdk/flutter. Consider adding
          /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to
          /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter.
          Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front
          of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 55c988fb45 (4 hours ago), 2023-04-27 20:32:55 -0400
        • Engine revision 1d25906b4c
        • Dart version 3.1.0 (build 3.1.0-49.0.dev)
        • DevTools version 2.23.1
        • 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 30.0.3)
        • Android SDK at /Users/dhs/Library/Android/sdk
        ✗ cmdline-tools component is missing
          Run `path/to/sdkmanager --install "cmdline-tools;latest"`
          See https://developer.android.com/studio/command-line for more details.
        ✗ Android license status unknown.
          Run `flutter doctor --android-licenses` to accept the SDK licenses.
          See https://flutter.dev/docs/get-started/install/macos#android-setup for
          more details.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 13C100
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2)
        • IntelliJ at /Applications/IntelliJ IDEA.app
        • Flutter plugin version 65.1.4
        • Dart plugin version 213.7228
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.29.0
    
    [✓] Connected device (3 available)
        • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios
          • iOS 15.3.1 19D52
        • macOS (desktop)           • macos                                    •
          darwin-x64     • macOS 12.2.1 21D62 darwin-x64
        • Chrome (web)              • chrome                                   •
          web-javascript • Google Chrome 109.0.5414.119
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
          
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    
    
    
  2. added
    packageflutter/packages repository. See also p: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on May 2, 2023
  3. added
    P2Important issues not at the top of the work list
    on May 2, 2023
  4. dalenjohnson commented on Jul 13, 2023

    @dalenjohnson
    Author

    Updated the code sample to fix the breaking changes in the last couple of go_router releases. Currently seeing the issue on go_router 9.0.3

    Updated code sample
    import 'package:flutter/material.dart';
    import 'package:go_router/go_router.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    final shellKey = GlobalKey<NavigatorState>();
    
    class MyApp extends StatelessWidget {
      MyApp({Key? key}) : super(key: key);
    
      final _router = GoRouter(
        initialLocation: '/',
        debugLogDiagnostics: true,
        routes: [
          ShellRoute(
            navigatorKey: shellKey,
            builder: (context, state, child) => ShellScaffold(child: child),
            pageBuilder: (context, state, child) =>
                MaterialPage(child: ShellScaffold(child: child)),
            routes: [
              GoRoute(
                name: 'Home',
                path: '/',
                builder: (context, state) => const Home(),
                routes: [
                  GoRoute(
                    name: 'Page A',
                    path: 'a',
                    builder: (context, state) => const PageA(),
                    routes: [
                      GoRoute(
                        name: 'Page B',
                        path: 'b',
                        builder: (context, state) => const PageB(),
                        routes: [
                          GoRoute(
                            name: 'Page C',
                            path: ':id',
                            builder: (context, state) => PageCWithParam(
                              id: state.pathParameters['id']!,
                            ),
                          ),
                        ],
                      ),
                    ],
                  ),
                ],
              ),
            ],
          )
        ],
      );
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp.router(
          title: 'Shell Route State Test',
          theme: ThemeData(
            colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
            useMaterial3: true,
          ),
          routerConfig: _router,
        );
      }
    }
    
    class ShellScaffold extends StatelessWidget {
      const ShellScaffold({Key? key, required this.child}) : super(key: key);
      final Widget child;
    
      @override
      Widget build(BuildContext context) {
        final state = GoRouterState.of(context);
    
        ///Below is a workaround after the 9.0.0 changes that remove GoRouter.location
        ///This can be used to get the actual location when pushing a route onto the ShellRoute.
        ///GoRouterState is incomplete for pushed/imperative routes as of 9.0.3
        GoRouter router = GoRouter.of(context);
        final RouteMatch lastMatch =
            router.routerDelegate.currentConfiguration.last;
        final RouteMatchList matchList = lastMatch is ImperativeRouteMatch
            ? lastMatch.matches
            : router.routerDelegate.currentConfiguration;
        final String location = matchList.uri.toString();
    
        print('ShellScaffold build');
        print('location: $location');
        print('GoRouterState location: ${state.location}');
        print('GoRouterState matchedLocation: ${state.matchedLocation}');
        print('GoRouterState fullPath: ${state.fullPath}');
        print('GoRouterState pathParameters: ${state.pathParameters}');
        return Scaffold(
          appBar: AppBar(
            title: Text(state.location),
            // automaticallyImplyLeading: true,
            /// automaticallyImplyLeading does not seem work inside of a ShellRoute.
            /// Manually defining leading below is then required to show a back button.
            /// This is why having a correct GoRouterState is needed.
            leading: (state.location.startsWith('/a'))
                ? BackButton(
                    onPressed: () => context.pop(),
                  )
                : null,
            actions: [
              /// Used to reset the state of the current path and return to home.
              IconButton(
                  onPressed: () => context.go('/'), icon: const Icon(Icons.home))
            ],
          ),
          body: child,
        );
      }
    }
    
    class Home extends StatelessWidget {
      const Home({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Center(
            child: Column(
              children: [
                const Text('Home'),
                TextButton(
                  onPressed: () => context.go('/a'),
                  child: const Text('Go /a'),
                ),
                TextButton(
                  onPressed: () => context.push('/a'),
                  child: const Text('Push /a'),
                ),
              ],
            ),
          ),
        );
      }
    }
    
    class PageA extends StatelessWidget {
      const PageA({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Center(
            child: Column(
              children: [
                const Text('Page A'),
                TextButton(
                  onPressed: () => context.go('/a/b'),
                  child: const Text('Go /a/b'),
                ),
                TextButton(
                  onPressed: () => context.push('/a/b'),
                  child: const Text('Push /a/b'),
                ),
                TextButton(
                  onPressed: () => context.pop(),
                  child: const Text('pop'),
                ),
              ],
            ),
          ),
        );
      }
    }
    
    class PageB extends StatelessWidget {
      const PageB({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return Center(
          child: Column(
            children: [
              const Text('Page B'),
              TextButton(
                onPressed: () => context.go('/a/b/1'),
                child: const Text('Go /a/b/1'),
              ),
              TextButton(
                onPressed: () => context.push('/a/b/2'),
                child: const Text('Push /a/b/2'),
              ),
              TextButton(
                onPressed: () => context.pop(),
                child: const Text('pop'),
              ),
            ],
          ),
        );
      }
    }
    
    class PageCWithParam extends StatelessWidget {
      const PageCWithParam({Key? key, required this.id}) : super(key: key);
      final String id;
      @override
      Widget build(BuildContext context) {
        return Center(
          child: Column(
            children: [
              Text('Page C with param: $id'),
              TextButton(
                onPressed: () => context.pop(),
                child: const Text('pop'),
              ),
            ],
          ),
        );
      }
    }
    
    
  5. gnunicorn commented on Oct 3, 2023

    @gnunicorn

    Piling onto that. Having two separate ShellRoutes, we are seeing the wrong ShellRoute being used when using push - but it is all fine using go.

    Example Code (against 10.1.2, 11.1.0)

    ```dart

    import 'package:flutter/material.dart';
    import 'package:go_router/go_router.dart';

    final GlobalKey rootNavKey = GlobalKey(
    debugLabel: 'root',
    );

    class MyApp extends StatelessWidget {
    const MyApp({super.key});

    @OverRide
    Widget build(BuildContext context) {
    return MaterialApp.router(
    title: 'Flutter Demo',
    routerConfig: GoRouter(
    initialLocation: '/a',
    routes: [
    ShellRoute( // App Base
    pageBuilder: (context, state, child) {
    return NoTransitionPage(
    key: state.pageKey,
    child: Scaffold(
    body: Column(
    crossAxisAlignment: CrossAxisAlignment.stretch,
    children: [
    Text('App Route'),
    Expanded(child: child),
    ],
    ),
    ),);
    },
    routes: [
    GoRoute(
    path: '/c',
    pageBuilder: (context, state) {
    return NoTransitionPage(
    key: state.pageKey,
    child: const Text("other"),
    );
    },
    ),
    ShellRoute(
    pageBuilder: (context, state, child) {
    return NoTransitionPage(
    key: state.pageKey,
    child: Scaffold(
    body: Column(
    crossAxisAlignment: CrossAxisAlignment.stretch,
    children: [
    Text('ShellRoute header A:'),
    Expanded(child: child),
    ],
    ),
    ),);
    },
    routes: [
    GoRoute(
    path: '/a',
    name: 'aIndex',
    builder: (context, state) => Column(children: [Text('a: index'),
    OutlinedButton(child: Text('go to a'), onPressed: () => context.goNamed('aIndex')),
    OutlinedButton(child: Text('go to b:details'), onPressed: () => context.goNamed('bDetails', pathParameters: {'roomId': '1244'})),
    OutlinedButton(child: Text('push to a:details'), onPressed: () => context.pushNamed('aDetails')),
    OutlinedButton(child: Text('push to b:details'), onPressed: () => context.pushNamed('bDetails', pathParameters: {'roomId': '1244'}))]),
    ),
    GoRoute(
    path: '/a/details',
    name: 'aDetails',
    builder: (context, state) => Column(children: [Text('a: details'),
    OutlinedButton(child: Text('go to a'), onPressed: () => context.goNamed('aIndex')),
    OutlinedButton(child: Text('go to b:details'), onPressed: () => context.goNamed('bDetails', pathParameters: {'roomId': '1244'})),
    OutlinedButton(child: Text('push to a'), onPressed: () => context.pushNamed('aIndex')),
    OutlinedButton(child: Text('push to b:details'), onPressed: () => context.pushNamed('bDetails', pathParameters: {'roomId': '1244'}))]),
    ),
    ],
    ),

          ShellRoute(
            pageBuilder: (context, state, child) {
              return  NoTransitionPage(
          key: state.pageKey,
          child:Scaffold(
                body: Column(
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: [
                    Text('ShellRoute header B:'),
                    Expanded(child: child),
                  ],
                ),),
              );
            },
            routes: [
              GoRoute(
                name: 'bIndex',
                path: '/b',
                builder: (context, state) => Text('b: index'),
              ),
              GoRoute(
                name: 'bDetails',
                path: '/b/:roomId/details',
                builder: (context, state) => Column(children: [Text('b: details'),
                                                               OutlinedButton(child: Text('push to a'), onPressed: () => context.pushNamed('aIndex')), 
                                                               OutlinedButton(child: Text('push to b'), onPressed: () => context.pushNamed('bIndex'))]),
              ),
            ],
          )
        ],
      ),
          ],),
    );
    

    }
    }

    void main() async {
    runApp(MyApp());
    }

    
    
    </p>
    </details> 
    
  6. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jan 2, 2024
  7. github-actions commented on Jan 16, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  8. locked as resolved and limited conversation to collaborators on Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.10Found to occur in 3.10found in release: 3.7Found to occur in 3.7has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions