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
6cfb86fb
Unverified
Commit
6cfb86fb
authored
Oct 26, 2020
by
chunhtai
Committed by
GitHub
Oct 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix crash if update pages right after a navigator pop (#68923)
parent
27e1efc1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
6 deletions
+47
-6
navigator.dart
packages/flutter/lib/src/widgets/navigator.dart
+10
-6
navigator_test.dart
packages/flutter/test/widgets/navigator_test.dart
+37
-0
No files found.
packages/flutter/lib/src/widgets/navigator.dart
View file @
6cfb86fb
...
...
@@ -985,11 +985,15 @@ class DefaultTransitionDelegate<T> extends TransitionDelegate<T> {
if
(
hasPagelessRoute
)
{
final
List
<
RouteTransitionRecord
>
pagelessRoutes
=
pageRouteToPagelessRoutes
[
exitingPageRoute
]!;
for
(
final
RouteTransitionRecord
pagelessRoute
in
pagelessRoutes
)
{
assert
(
pagelessRoute
.
isWaitingForExitingDecision
);
if
(
isLastExitingPageRoute
&&
pagelessRoute
==
pagelessRoutes
.
last
)
{
pagelessRoute
.
markForPop
(
pagelessRoute
.
route
.
currentResult
);
}
else
{
pagelessRoute
.
markForComplete
(
pagelessRoute
.
route
.
currentResult
);
// It is possible that a pageless route that belongs to an exiting
// page-based route does not require exiting decision. This can
// happen if the page list is updated right after a Navigator.pop.
if
(
pagelessRoute
.
isWaitingForExitingDecision
)
{
if
(
isLastExitingPageRoute
&&
pagelessRoute
==
pagelessRoutes
.
last
)
{
pagelessRoute
.
markForPop
(
pagelessRoute
.
route
.
currentResult
);
}
else
{
pagelessRoute
.
markForComplete
(
pagelessRoute
.
route
.
currentResult
);
}
}
}
}
...
...
@@ -3655,7 +3659,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin, Res
()
=>
<
_RouteEntry
>[],
);
pagelessRoutes
.
add
(
potentialEntryToRemove
);
if
(
previousOldPageRouteEntry
!.
isWaitingForExitingDecision
)
if
(
previousOldPageRouteEntry
!.
isWaitingForExitingDecision
&&
potentialEntryToRemove
.
isPresent
)
potentialEntryToRemove
.
markNeedsExitingDecision
();
continue
;
}
...
...
packages/flutter/test/widgets/navigator_test.dart
View file @
6cfb86fb
...
...
@@ -3195,6 +3195,43 @@ void main() {
expect
(
find
.
text
(
'initial'
),
findsOneWidget
);
});
testWidgets
(
'can update pages before a pageless route has finished popping'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/68162.
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
(
pages:
myPages
,
onPopPage:
onPopPage
,
key:
navigator
)
);
// Pushes a pageless route.
showDialog
<
void
>(
useRootNavigator:
false
,
context:
navigator
.
currentContext
!,
builder:
(
BuildContext
context
)
=>
const
Text
(
'dialog'
)
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'dialog'
),
findsOneWidget
);
// Pops the pageless route.
navigator
.
currentState
!.
pop
();
// Before the pop finishes, updates the page list.
myPages
=
<
TestPage
>[
const
TestPage
(
key:
ValueKey
<
String
>(
'1'
),
name:
'initial'
),
];
await
tester
.
pumpWidget
(
buildNavigator
(
pages:
myPages
,
onPopPage:
onPopPage
,
key:
navigator
)
);
// It should not crash the app.
expect
(
tester
.
takeException
(),
isNull
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'initial'
),
findsOneWidget
);
});
testWidgets
(
'pages remove and add trigger observer in the right order'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
NavigatorState
>
navigator
=
GlobalKey
<
NavigatorState
>();
List
<
TestPage
>
myPages
=
<
TestPage
>[
...
...
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