File tree 2 files changed +12
-20
lines changed
packages/go_router/lib/src 2 files changed +12
-20
lines changed Original file line number Diff line number Diff line change @@ -148,9 +148,18 @@ class GoRouterDelegate extends RouterDelegate<RouteMatchList>
148
148
return navigatorKey.currentState? .canPop () ?? false ;
149
149
}
150
150
151
+ void _debugAssertMatchListNotEmpty () {
152
+ assert (
153
+ _matchList.isNotEmpty,
154
+ 'You have popped the last page off of the stack,'
155
+ ' there are no pages left to show' ,
156
+ );
157
+ }
158
+
151
159
/// Pop the top page off the GoRouter's page stack.
152
160
void pop () {
153
161
_matchList.pop ();
162
+ _debugAssertMatchListNotEmpty ();
154
163
notifyListeners ();
155
164
}
156
165
@@ -159,10 +168,8 @@ class GoRouterDelegate extends RouterDelegate<RouteMatchList>
159
168
/// See also:
160
169
/// * [push] which pushes the given location onto the page stack.
161
170
void replace (RouteMatch match) {
162
- // We pop the current page. There is no need to verify the match list is not
163
- // empty during the pop because we are going to push a new page right away.
164
- _matchList.pop (asserts: false );
165
- push (match); // [push] will notify listeners.
171
+ _matchList.pop ();
172
+ push (match); // [push] will notify the listeners.
166
173
}
167
174
168
175
/// For internal use; visible for testing only.
Original file line number Diff line number Diff line change @@ -71,21 +71,13 @@ class RouteMatchList {
71
71
}
72
72
73
73
/// Removes the last match.
74
- void pop ({ bool asserts = true } ) {
74
+ void pop () {
75
75
_matches.removeLast ();
76
76
77
- if (asserts) {
78
- _debugAssertNotEmpty ();
79
- }
80
-
81
77
// Also pop ShellRoutes when there are no subsequent route matches
82
78
while (_matches.isNotEmpty && _matches.last.route is ShellRoute ) {
83
79
_matches.removeLast ();
84
80
}
85
-
86
- if (asserts) {
87
- _debugAssertNotEmpty ();
88
- }
89
81
}
90
82
91
83
/// An optional object provided by the app during navigation.
@@ -102,13 +94,6 @@ class RouteMatchList {
102
94
103
95
/// Returns the error that this match intends to display.
104
96
Exception ? get error => matches.first.error;
105
-
106
- void _debugAssertNotEmpty () {
107
- assert (
108
- _matches.isNotEmpty,
109
- 'You have popped the last page off of the stack,'
110
- ' there are no pages left to show' );
111
- }
112
97
}
113
98
114
99
/// An error that occurred during matching.
You can’t perform that action at this time.
0 commit comments