diff --git a/packages/go_router/lib/src/builder.dart b/packages/go_router/lib/src/builder.dart index 72d0574eb913..f03444ffa2b3 100644 --- a/packages/go_router/lib/src/builder.dart +++ b/packages/go_router/lib/src/builder.dart @@ -114,12 +114,22 @@ class RouteBuilder { GlobalKey navigatorKey, Map, GoRouterState> registry, ) { + List>? pages; + if (routerNeglect) { + Router.neglect(context, () { + pages = buildPages(context, matchList, onPopPage, routerNeglect, + navigatorKey, registry); + }); + } else { + pages = buildPages( + context, matchList, onPopPage, routerNeglect, navigatorKey, registry); + } + assert(pages != null); return builderWithNav( context, _buildNavigator( onPopPage, - buildPages(context, matchList, onPopPage, routerNeglect, navigatorKey, - registry), + pages!, navigatorKey, observers: observers, ),