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
2f04ba91
Unverified
Commit
2f04ba91
authored
May 06, 2020
by
chunhtai
Committed by
GitHub
May 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes the navigator pages update crashes when there is still route wa… (#55998)
parent
c2b7342c
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
179 additions
and
95 deletions
+179
-95
navigator.dart
packages/flutter/lib/src/widgets/navigator.dart
+108
-85
navigator_test.dart
packages/flutter/test/widgets/navigator_test.dart
+71
-10
No files found.
packages/flutter/lib/src/widgets/navigator.dart
View file @
2f04ba91
This diff is collapsed.
Click to expand it.
packages/flutter/test/widgets/navigator_test.dart
View file @
2f04ba91
...
...
@@ -2367,6 +2367,66 @@ void main() {
expect
(
find
.
text
(
'forth'
),
findsOneWidget
);
});
testWidgets
(
'can repush a page that was previously popped before it has finished popping'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
NavigatorState
>
navigator
=
GlobalKey
<
NavigatorState
>();
List
<
Page
<
dynamic
>>
myPages
=
<
TestPage
>[
const
TestPage
(
key:
ValueKey
<
String
>(
'1'
),
name:
'initial'
),
const
TestPage
(
key:
ValueKey
<
String
>(
'2'
),
name:
'second'
),
];
bool
onPopPage
(
Route
<
dynamic
>
route
,
dynamic
result
)
{
myPages
.
removeWhere
((
Page
<
dynamic
>
page
)
=>
route
.
settings
==
page
);
return
route
.
didPop
(
result
);
}
await
tester
.
pumpWidget
(
buildNavigator
(
myPages
,
onPopPage
,
navigator
));
// Pops the second page route.
myPages
=
<
TestPage
>[
const
TestPage
(
key:
ValueKey
<
String
>(
'1'
),
name:
'initial'
),
];
await
tester
.
pumpWidget
(
buildNavigator
(
myPages
,
onPopPage
,
navigator
));
// Re-push the second page again before it finishes popping.
myPages
=
<
TestPage
>[
const
TestPage
(
key:
ValueKey
<
String
>(
'1'
),
name:
'initial'
),
const
TestPage
(
key:
ValueKey
<
String
>(
'2'
),
name:
'second'
),
];
await
tester
.
pumpWidget
(
buildNavigator
(
myPages
,
onPopPage
,
navigator
));
// It should not crash the app.
expect
(
tester
.
takeException
(),
isNull
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'second'
),
findsOneWidget
);
});
testWidgets
(
'can update pages before a route has finished popping'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
NavigatorState
>
navigator
=
GlobalKey
<
NavigatorState
>();
List
<
Page
<
dynamic
>>
myPages
=
<
TestPage
>[
const
TestPage
(
key:
ValueKey
<
String
>(
'1'
),
name:
'initial'
),
const
TestPage
(
key:
ValueKey
<
String
>(
'2'
),
name:
'second'
),
];
bool
onPopPage
(
Route
<
dynamic
>
route
,
dynamic
result
)
{
myPages
.
removeWhere
((
Page
<
dynamic
>
page
)
=>
route
.
settings
==
page
);
return
route
.
didPop
(
result
);
}
await
tester
.
pumpWidget
(
buildNavigator
(
myPages
,
onPopPage
,
navigator
));
// Pops the second page route.
myPages
=
<
TestPage
>[
const
TestPage
(
key:
ValueKey
<
String
>(
'1'
),
name:
'initial'
),
];
await
tester
.
pumpWidget
(
buildNavigator
(
myPages
,
onPopPage
,
navigator
));
// Updates the pages again before second page finishes popping.
myPages
=
<
TestPage
>[
const
TestPage
(
key:
ValueKey
<
String
>(
'1'
),
name:
'initial'
),
];
await
tester
.
pumpWidget
(
buildNavigator
(
myPages
,
onPopPage
,
navigator
));
// It should not crash the app.
expect
(
tester
.
takeException
(),
isNull
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'initial'
),
findsOneWidget
);
});
});
}
...
...
@@ -2415,23 +2475,24 @@ class AlwaysRemoveTransitionDelegate extends TransitionDelegate<void> {
return
;
final
RouteTransitionRecord
exitingPageRoute
=
locationToExitingPageRoute
[
location
];
final
bool
hasPagelessRoute
=
pageRouteToPagelessRoutes
.
containsKey
(
exitingPageRoute
);
exitingPageRoute
.
markForRemove
();
results
.
add
(
exitingPageRoute
);
if
(
hasPagelessRoute
)
{
final
List
<
RouteTransitionRecord
>
pagelessRoutes
=
pageRouteToPagelessRoutes
[
exitingPageRoute
];
for
(
final
RouteTransitionRecord
pagelessRoute
in
pagelessRoutes
)
{
pagelessRoute
.
markForRemove
();
if
(
exitingPageRoute
.
isWaitingForExitingDecision
)
{
final
bool
hasPagelessRoute
=
pageRouteToPagelessRoutes
.
containsKey
(
exitingPageRoute
);
exitingPageRoute
.
markForRemove
();
if
(
hasPagelessRoute
)
{
final
List
<
RouteTransitionRecord
>
pagelessRoutes
=
pageRouteToPagelessRoutes
[
exitingPageRoute
];
for
(
final
RouteTransitionRecord
pagelessRoute
in
pagelessRoutes
)
{
pagelessRoute
.
markForRemove
();
}
}
}
results
.
add
(
exitingPageRoute
);
handleExitingRoute
(
exitingPageRoute
);
}
handleExitingRoute
(
null
);
for
(
final
RouteTransitionRecord
pageRoute
in
newPageRouteHistory
)
{
if
(
pageRoute
.
is
Entering
)
{
if
(
pageRoute
.
is
WaitingForEnteringDecision
)
{
pageRoute
.
markForAdd
();
}
results
.
add
(
pageRoute
);
...
...
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