Skip to content

Commit 7dbe8f6

Browse files
committed
alter structure
1 parent 2d55e2b commit 7dbe8f6

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

packages/go_router/lib/src/delegate.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,17 @@ class GoRouterDelegate extends RouterDelegate<RouteMatchList>
105105
states.first.pop(result);
106106
}
107107

108-
/// Get a prioritized list of NavigatorStates
109-
/// 1. Pop routes within branches of shell navigation which `canPop`
110-
/// 2. Pop parent route
111-
/// 3. Pop branch routes (which are exit routes as they cannot be popped)
108+
/// Get a prioritized list of NavigatorStates,
109+
/// which either can pop or are exit routes.
110+
///
111+
/// 1. Sub route within branches of shell navigation
112+
/// 2. Branch route
113+
/// 3. Parent route
112114
List<NavigatorState> _findCurrentNavigators() {
113115
final List<NavigatorState> states = <NavigatorState>[];
114116
if (navigatorKey.currentState != null) {
115-
states.add(navigatorKey
116-
.currentState!); // Set state directly without canPop check
117+
// Set state directly without canPop check
118+
states.add(navigatorKey.currentState!);
117119
}
118120

119121
RouteMatchBase walker = currentConfiguration.matches.last;
@@ -127,8 +129,7 @@ class GoRouterDelegate extends RouterDelegate<RouteMatchList>
127129
// Stop if there is a pageless route on top of the shell route.
128130
break;
129131
}
130-
states.insert(
131-
potentialCandidate.canPop() ? 0 : states.length, potentialCandidate);
132+
states.insert(0, potentialCandidate);
132133
walker = walker.matches.last;
133134
}
134135
return states;

0 commit comments

Comments
 (0)