Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
1bb9f3f7
Unverified
Commit
1bb9f3f7
authored
May 12, 2020
by
chunhtai
Committed by
GitHub
May 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix pushAndRemoveUntil incorrectly removes the routes below the first… (#56732)
parent
c969b8af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
3 deletions
+38
-3
navigator.dart
packages/flutter/lib/src/widgets/navigator.dart
+2
-3
navigator_test.dart
packages/flutter/test/widgets/navigator_test.dart
+36
-0
No files found.
packages/flutter/lib/src/widgets/navigator.dart
View file @
1bb9f3f7
...
...
@@ -3435,9 +3435,8 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
assert
(
predicate
!=
null
);
int
index
=
_history
.
length
-
1
;
_history
.
add
(
_RouteEntry
(
newRoute
,
initialState:
_RouteLifecycle
.
push
));
while
(
index
>=
0
)
{
final
_RouteEntry
entry
=
_history
[
index
];
if
(
entry
.
isPresent
&&
!
predicate
(
entry
.
route
))
while
(
index
>=
0
&&
!
predicate
(
_history
[
index
].
route
))
{
if
(
_history
[
index
].
isPresent
)
_history
[
index
].
remove
();
index
-=
1
;
}
...
...
packages/flutter/test/widgets/navigator_test.dart
View file @
1bb9f3f7
...
...
@@ -682,6 +682,42 @@ void main() {
expect
(
find
.
text
(
'B'
),
isOnstage
);
});
testWidgets
(
'pushAndRemoveUntil does not remove routes below the first route that pass the predicate'
,
(
WidgetTester
tester
)
async
{
// Regression https://github.com/flutter/flutter/issues/56688
final
GlobalKey
<
NavigatorState
>
navigator
=
GlobalKey
<
NavigatorState
>();
final
Map
<
String
,
WidgetBuilder
>
routes
=
<
String
,
WidgetBuilder
>{
'/'
:
(
BuildContext
context
)
=>
const
Text
(
'home'
),
'/A'
:
(
BuildContext
context
)
=>
const
Text
(
'page A'
),
'/A/B'
:
(
BuildContext
context
)
=>
OnTapPage
(
id:
'B'
,
onTap:
()
{
Navigator
.
of
(
context
).
pushNamedAndRemoveUntil
(
'/D'
,
ModalRoute
.
withName
(
'/A'
));
},
),
'/D'
:
(
BuildContext
context
)
=>
const
Text
(
'page D'
),
};
await
tester
.
pumpWidget
(
MaterialApp
(
navigatorKey:
navigator
,
routes:
routes
,
initialRoute:
'/A/B'
,
)
);
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
text
(
'B'
));
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'page D'
),
isOnstage
);
navigator
.
currentState
.
pop
();
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'page A'
),
isOnstage
);
navigator
.
currentState
.
pop
();
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'home'
),
isOnstage
);
});
testWidgets
(
'replaceNamed returned value'
,
(
WidgetTester
tester
)
async
{
Future
<
String
>
value
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment