diff --git a/packages/go_router/lib/src/builder.dart b/packages/go_router/lib/src/builder.dart index 0cfdf5efa481..06bd0225885b 100644 --- a/packages/go_router/lib/src/builder.dart +++ b/packages/go_router/lib/src/builder.dart @@ -128,12 +128,22 @@ class RouteBuilder { // https://github.com/flutter/flutter/issues/126365 final _PagePopContext pagePopContext = _PagePopContext._(onPopPageWithRouteMatch); + List>? pages; + if (routerNeglect) { + Router.neglect(context, () { + pages = _buildPages(context, matchList, pagePopContext, routerNeglect, + navigatorKey, registry); + }); + } else { + pages = _buildPages(context, matchList, pagePopContext, routerNeglect, + navigatorKey, registry); + } + assert(pages != null); return builderWithNav( context, _buildNavigator( pagePopContext.onPopPage, - _buildPages(context, matchList, pagePopContext, routerNeglect, - navigatorKey, registry), + pages!, navigatorKey, observers: observers, restorationScopeId: restorationScopeId, diff --git a/packages/go_router/lib/src/parser.dart b/packages/go_router/lib/src/parser.dart index df4d551a8bf5..cc5ca7039cb4 100644 --- a/packages/go_router/lib/src/parser.dart +++ b/packages/go_router/lib/src/parser.dart @@ -129,16 +129,21 @@ class GoRouteInformationParser extends RouteInformationParser { if (configuration.isEmpty) { return null; } + final String location; if (GoRouter.optionURLReflectsImperativeAPIs && configuration.matches.last is ImperativeRouteMatch) { - configuration = - (configuration.matches.last as ImperativeRouteMatch).matches; + location = (configuration.matches.last as ImperativeRouteMatch) + .matches + .uri + .toString(); + } else { + location = configuration.uri.toString(); } return RouteInformation( // TODO(chunhtai): remove this ignore and migrate the code // https://github.com/flutter/flutter/issues/124045. // ignore: deprecated_member_use - location: configuration.uri.toString(), + location: location, state: _routeMatchListCodec.encode(configuration), ); }