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
64300123
Unverified
Commit
64300123
authored
Sep 14, 2019
by
LongCatIsLooong
Committed by
GitHub
Sep 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restore offstage and ticker mode after hero pop and the from hero is null (#40306)
parent
4d404da6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
1 deletion
+59
-1
heroes.dart
packages/flutter/lib/src/widgets/heroes.dart
+9
-1
heroes_test.dart
packages/flutter/test/widgets/heroes_test.dart
+50
-0
No files found.
packages/flutter/lib/src/widgets/heroes.dart
View file @
64300123
...
...
@@ -359,7 +359,8 @@ class _HeroState extends State<Hero> {
}
// When `keepPlaceholder` is true, the placeholder will continue to be shown
// after the flight ends.
// after the flight ends. Otherwise the child of the Hero will become visible
// and its TickerMode will be re-enabled.
void
endFlight
({
bool
keepPlaceholder
=
false
})
{
if
(!
keepPlaceholder
)
{
ensurePlaceholderIsHidden
();
...
...
@@ -833,6 +834,13 @@ class HeroController extends NavigatorObserver {
_flights
[
tag
].
abort
();
}
}
// If the from hero is gone, the flight won't start and the to hero needs to
// be put on stage again.
for
(
Object
tag
in
toHeroes
.
keys
)
{
if
(
fromHeroes
[
tag
]
==
null
)
toHeroes
[
tag
].
ensurePlaceholderIsHidden
();
}
}
void
_handleFlightEnded
(
_HeroFlight
flight
)
{
...
...
packages/flutter/test/widgets/heroes_test.dart
View file @
64300123
...
...
@@ -2256,6 +2256,56 @@ Future<void> main() async {
);
});
// Regression test for https://github.com/flutter/flutter/issues/40239.
testWidgets
(
'In a pop transition, when fromHero is null, the to hero should eventually become visible'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
NavigatorState
>
navigatorKey
=
GlobalKey
();
StateSetter
setState
;
bool
shouldDisplayHero
=
true
;
await
tester
.
pumpWidget
(
CupertinoApp
(
navigatorKey:
navigatorKey
,
home:
Hero
(
tag:
navigatorKey
,
child:
const
Placeholder
(),
),
),
);
final
CupertinoPageRoute
<
void
>
route2
=
CupertinoPageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
CupertinoPageScaffold
(
child:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setter
)
{
setState
=
setter
;
return
shouldDisplayHero
?
Hero
(
tag:
navigatorKey
,
child:
const
Text
(
'text'
))
:
const
SizedBox
();
},
),
);
},
);
navigatorKey
.
currentState
.
push
(
route2
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'text'
),
findsOneWidget
);
expect
(
find
.
byType
(
Placeholder
),
findsNothing
);
setState
(()
{
shouldDisplayHero
=
false
;
});
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'text'
),
findsNothing
);
navigatorKey
.
currentState
.
pop
();
await
tester
.
pumpAndSettle
();
expect
(
find
.
byType
(
Placeholder
),
findsOneWidget
);
},
);
testWidgets
(
'popped hero uses fastOutSlowIn curve'
,
(
WidgetTester
tester
)
async
{
final
Key
container1
=
UniqueKey
();
final
Key
container2
=
UniqueKey
();
...
...
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