Skip to content

[go_router] Come up with a better way to get the current location without context #129833

@ghaith-abtah-5

Description

@ghaith-abtah-5

Is there an existing issue for this?

Use case

After the last update go_router 9.0.0, you have removed the location parameter from GoRouter and cannot be accessed any more without a context.

final GoRouter router = GoRouter(
     routes: [
          GoRoute(
                path: Routes.splashRoute,
                builder: (BuildContext context, GoRouterState state) {
                initSplashModule();
                return const SplashScreen();
                 },
               routes: [...],
               ],
            ),
           // other routes
        ],
     );

I cannot anymore use router.location to determine where am I in the application and there are certain scenarios where I cannot provide a context to GoRouterState.of(context).location, deep link or firebase messages that will pop or push some other routes from or to the navigation stack depending on the current location and state.
It was the easiest way to get the location and I can implement a way to do this on my own but it will take so much time and effort to get to the go_router package level.

Proposal

What was the reason to remove the location parameter and is there any chance that it will be back without a context in future versions?

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: proposalA detailed proposal for a change to Flutterd: api docsIssues with https://api.flutter.dev/p: 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

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions