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
89c8616f
Unverified
Commit
89c8616f
authored
Jul 20, 2021
by
Taha Tesser
Committed by
GitHub
Jul 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix `_owner` nullability in `routers.dart` (#84840)
parent
0504fac7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
2 deletions
+47
-2
routes.dart
packages/flutter/lib/src/widgets/routes.dart
+1
-1
routes_test.dart
packages/flutter/test/widgets/routes_test.dart
+46
-1
No files found.
packages/flutter/lib/src/widgets/routes.dart
View file @
89c8616f
...
...
@@ -447,7 +447,7 @@ class LocalHistoryEntry {
/// Remove this entry from the history of its associated [LocalHistoryRoute].
void
remove
()
{
_owner
!
.
removeLocalHistoryEntry
(
this
);
_owner
?
.
removeLocalHistoryEntry
(
this
);
assert
(
_owner
==
null
);
}
...
...
packages/flutter/test/widgets/routes_test.dart
View file @
89c8616f
...
...
@@ -1701,7 +1701,6 @@ void main() {
state
.
addLocalHistory
();
// Waits for modal route to update its internal state;
await
tester
.
pump
();
// Pumps a new widget to dispose WidgetWithLocalHistory. This should cause
// it to remove the local history entry from modal route during
// finalizeTree.
...
...
@@ -1712,6 +1711,25 @@ void main() {
await
tester
.
pump
();
expect
(
tester
.
takeException
(),
null
);
});
testWidgets
(
'child with no local history can be disposed'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
WidgetWithNoLocalHistory
(),
));
final
WidgetWithNoLocalHistoryState
state
=
tester
.
state
(
find
.
byType
(
WidgetWithNoLocalHistory
));
state
.
addLocalHistory
();
// Waits for modal route to update its internal state;
await
tester
.
pump
();
// Pumps a new widget to dispose WidgetWithNoLocalHistory. This should cause
// it to remove the local history entry from modal route during
// finalizeTree.
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Text
(
'dummy'
),
));
await
tester
.
pump
();
expect
(
tester
.
takeException
(),
null
);
});
});
testWidgets
(
'can be dismissed with escape keyboard shortcut'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -1972,6 +1990,33 @@ class WidgetWithLocalHistoryState extends State<WidgetWithLocalHistory> {
}
}
class
WidgetWithNoLocalHistory
extends
StatefulWidget
{
const
WidgetWithNoLocalHistory
({
Key
?
key
})
:
super
(
key:
key
);
@override
WidgetWithNoLocalHistoryState
createState
()
=>
WidgetWithNoLocalHistoryState
();
}
class
WidgetWithNoLocalHistoryState
extends
State
<
WidgetWithNoLocalHistory
>
{
late
LocalHistoryEntry
_localHistory
;
void
addLocalHistory
()
{
_localHistory
=
LocalHistoryEntry
();
// Not calling `route.addLocalHistoryEntry` here.
}
@override
void
dispose
()
{
super
.
dispose
();
_localHistory
.
remove
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
const
Text
(
'dummy'
);
}
}
class
TransitionDetector
extends
DefaultTransitionDelegate
<
void
>
{
bool
hasTransition
=
false
;
@override
...
...
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