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
955e004a
Commit
955e004a
authored
Mar 15, 2019
by
Efthymis Sarmpanis
Committed by
Kate Lovett
Mar 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Throw assertion error when a Hero has a Hero child. (#28470)
parent
439fbbe6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
0 deletions
+90
-0
heroes.dart
packages/flutter/lib/src/widgets/heroes.dart
+6
-0
heroes_test.dart
packages/flutter/test/widgets/heroes_test.dart
+84
-0
No files found.
packages/flutter/lib/src/widgets/heroes.dart
View file @
955e004a
...
@@ -126,6 +126,7 @@ class Hero extends StatefulWidget {
...
@@ -126,6 +126,7 @@ class Hero extends StatefulWidget {
/// Create a hero.
/// Create a hero.
///
///
/// The [tag] and [child] parameters must not be null.
/// The [tag] and [child] parameters must not be null.
/// The [child] parameter and all of the its descendants must not be [Hero]s.
const
Hero
({
const
Hero
({
Key
key
,
Key
key
,
@required
this
.
tag
,
@required
this
.
tag
,
...
@@ -295,6 +296,11 @@ class _HeroState extends State<Hero> {
...
@@ -295,6 +296,11 @@ class _HeroState extends State<Hero> {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
assert
(
context
.
ancestorWidgetOfExactType
(
Hero
)
==
null
,
'A Hero widget cannot be the descendant of another Hero widget.'
);
if
(
_placeholderSize
!=
null
)
{
if
(
_placeholderSize
!=
null
)
{
if
(
widget
.
placeholderBuilder
==
null
)
{
if
(
widget
.
placeholderBuilder
==
null
)
{
return
SizedBox
(
return
SizedBox
(
...
...
packages/flutter/test/widgets/heroes_test.dart
View file @
955e004a
...
@@ -1610,4 +1610,88 @@ void main() {
...
@@ -1610,4 +1610,88 @@ void main() {
expect
(
find
.
byKey
(
smallContainer
),
isInCard
);
expect
(
find
.
byKey
(
smallContainer
),
isInCard
);
expect
(
tester
.
getSize
(
find
.
byKey
(
smallContainer
)),
const
Size
(
100
,
100
));
expect
(
tester
.
getSize
(
find
.
byKey
(
smallContainer
)),
const
Size
(
100
,
100
));
});
});
testWidgets
(
'Hero within a Hero, throws'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Material
(
child:
Hero
(
tag:
'a'
,
child:
Hero
(
tag:
'b'
,
child:
Text
(
'Child of a Hero'
),
),
),
),
),
);
expect
(
tester
.
takeException
(),
isAssertionError
);
});
testWidgets
(
'Hero within a Hero subtree, throws'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
Container
(
child:
const
Hero
(
tag:
'a'
,
child:
Hero
(
tag:
'b'
,
child:
Text
(
'Child of a Hero'
),
),
),
),
),
),
);
expect
(
tester
.
takeException
(),
isAssertionError
);
});
testWidgets
(
'Hero within a Hero subtree with Builder, throws'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
Hero
(
tag:
'a'
,
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
const
Hero
(
tag:
'b'
,
child:
Text
(
'Child of a Hero'
),
);
},
),
),
),
),
);
expect
(
tester
.
takeException
(),
isAssertionError
);
});
testWidgets
(
'Hero within a Hero subtree with LayoutBuilder, throws'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
Hero
(
tag:
'a'
,
child:
LayoutBuilder
(
builder:
(
BuildContext
context
,
BoxConstraints
constraints
)
{
return
const
Hero
(
tag:
'b'
,
child:
Text
(
'Child of a Hero'
),
);
},
),
),
),
),
);
expect
(
tester
.
takeException
(),
isAssertionError
);
});
}
}
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