Closed johnpryan closed 2 years ago
The problem seems to be caused by GoRouteInformationParser._getLocRouteRecursively
and how it computes the match list.
In each recursion it iterates every GoRoute and creates a new match from it, passing last route query params without taking into account previous match configuration:
lib/src/go_route_information_parser.dart:329
static List<GoRouteMatch> _getLocRouteRecursively({
required String loc,
required String restLoc,
required String parentSubloc,
required List<GoRoute> routes,
required String parentFullpath,
required Map<String, String> queryParams,
required Object? extra,
}) {
bool debugGatherAllMatches = false;
assert(() {
debugGatherAllMatches = true;
return true;
}());
final List<List<GoRouteMatch>> result = <List<GoRouteMatch>>[];
// find the set of matches at this level of the tree
for (final GoRoute route in routes) {
final String fullpath = concatenatePaths(parentFullpath, route.path);
final GoRouteMatch? match = GoRouteMatch.match(
route: route,
restLoc: restLoc,
parentSubloc: parentSubloc,
fullpath: fullpath,
queryParams: queryParams, <------
extra: extra,
);
...
I am also not sure what the expected behavior should be, the previous page may rely on the query parameter.
If this is the intended behavior we need to specify it somewhere, otherwise we should consider it a bug. I'm not aware of any routing libraries that keep the query parameters after navigation occurs.
I think we either keep it, or the query parameters are only visible to the last match, WDYT? @johnpryan
After thinking about this some more, this is probably working as intended... Other route matches could be relying on the query parameters so it's not clear that we should clear them in this case.
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.
Pressing the in-app back button should clear the query parameters
Steps to reproduce:
/b?filter=abc
/?filter=abc
but should be/