Skip to content

[go_router] ShellRoute doesn't correctly parse GoRouterState.params #112444

@ahmednfwela

Description

@ahmednfwela

when there are router parameters present, GoRouterState.params in ShellRoute.builder doesn't get filled, but it gets filled in the relative GoRoute

sample app:

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  String logState(GoRouterState state) {
    return 'Current route: ${state.location}, params: ${state.params}, queryParams: ${state.queryParams}';
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      title: 'Flutter Demo',
      routerConfig: GoRouter(
        initialLocation: '/a',
        routes: [
          ShellRoute(
            builder: (context, state, child) {
              return Scaffold(
                body: Column(
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: [
                    Text('ShellRoute: ${logState(state)}'),
                    Expanded(child: child),
                  ],
                ),
              );
            },
            routes: [
              GoRoute(
                path: '/a',
                builder: (context, state) => Text('a: ${logState(state)}'),
              ),
              GoRoute(
                path: '/b/:bParam',
                builder: (context, state) => Text('b: ${logState(state)}'),
              ),
            ],
          )
        ],
      ),
    );
  }
}

Result:
image

Expected Result:
params in both should be the same

using go_router: ^5.0.2

Flutter (Channel master, 3.4.0-30.0.pre.18, on Microsoft Windows [Version 10.0.19043.2075], locale en-US)
    • Flutter version 3.4.0-30.0.pre.18 on channel master at C:\tools\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 9f5174f721 (28 hours ago), 2022-09-25 21:14:31 -0400
    • Engine revision 1c232b584c
    • Dart version 2.19.0 (build 2.19.0-240.0.dev)
    • DevTools version 2.17.0

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listfound in release: 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4has 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