I'm encountering an issue with accessing queryParams in my Flutter app while using the GoRouter package for routing. It seems that a recent update has caused a change in how queryParams can be accessed from a route at the point of definition. Here's a snippet of my code:
final _router = GoRouter(
routes: [
GoRoute(
path: OnBoardingScreen.route(),
name: OnBoardingScreen.route(),
builder: (context, state) {
return OnBoardingScreen(
next: state.queryParameters['next'],
);
},
),
],
);
Previously, I could access queryParams directly from the state. However, after the recent update, queryParams seems to be inaccessible from the state.
I would greatly appreciate any insights or suggestions on how to address this issue. Thank you in advance for your help!
The update 10.0.0 introduced some breaking changes, one of them is the removal of
queryParametersgetter fromGoRouterState.The full URI of the route is in the
uriproperty of the state, which includes the query parameters. You can access it with thequeryParametersgetter of theUriclass like this: