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
730a534f
Unverified
Commit
730a534f
authored
Jul 27, 2018
by
Jonah Williams
Committed by
GitHub
Jul 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Card explicitChildNodes vs container be configurable (#19693)
parent
9c159638
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
17 deletions
+76
-17
card.dart
packages/flutter/lib/src/material/card.dart
+16
-1
card_test.dart
packages/flutter/test/material/card_test.dart
+60
-16
No files found.
packages/flutter/lib/src/material/card.dart
View file @
730a534f
...
@@ -67,6 +67,7 @@ class Card extends StatelessWidget {
...
@@ -67,6 +67,7 @@ class Card extends StatelessWidget {
this
.
shape
,
this
.
shape
,
this
.
margin
=
const
EdgeInsets
.
all
(
4.0
),
this
.
margin
=
const
EdgeInsets
.
all
(
4.0
),
this
.
child
,
this
.
child
,
this
.
semanticContainer
=
false
,
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
/// The card's background color.
/// The card's background color.
...
@@ -100,6 +101,19 @@ class Card extends StatelessWidget {
...
@@ -100,6 +101,19 @@ class Card extends StatelessWidget {
/// `EdgeInsets.all(4.0)`.
/// `EdgeInsets.all(4.0)`.
final
EdgeInsetsGeometry
margin
;
final
EdgeInsetsGeometry
margin
;
/// Whether this widget represents a single semantic container, or if false
/// a collection of individual semantic nodes.
///
/// Defaults to false.
///
/// Setting this flag to true will attempt to merge all child semantics into
/// this node. Setting this flag to false will force all child semantic nodes
/// to be explicit.
///
/// This flag should be false if the card contains multiple different types
/// of content.
final
bool
semanticContainer
;
/// The widget below this widget in the tree.
/// The widget below this widget in the tree.
///
///
/// {@macro flutter.widgets.child}
/// {@macro flutter.widgets.child}
...
@@ -108,7 +122,8 @@ class Card extends StatelessWidget {
...
@@ -108,7 +122,8 @@ class Card extends StatelessWidget {
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
new
Semantics
(
return
new
Semantics
(
container:
true
,
container:
semanticContainer
,
explicitChildNodes:
!
semanticContainer
,
child:
new
Container
(
child:
new
Container
(
margin:
margin
??
const
EdgeInsets
.
all
(
4.0
),
margin:
margin
??
const
EdgeInsets
.
all
(
4.0
),
child:
new
Material
(
child:
new
Material
(
...
...
packages/flutter/test/material/card_test.dart
View file @
730a534f
...
@@ -18,6 +18,7 @@ void main() {
...
@@ -18,6 +18,7 @@ void main() {
child:
new
Material
(
child:
new
Material
(
child:
new
Center
(
child:
new
Center
(
child:
new
Card
(
child:
new
Card
(
semanticContainer:
false
,
child:
new
Column
(
child:
new
Column
(
children:
<
Widget
>[
children:
<
Widget
>[
const
Text
(
'I am text!'
),
const
Text
(
'I am text!'
),
...
@@ -37,25 +38,68 @@ void main() {
...
@@ -37,25 +38,68 @@ void main() {
expect
(
semantics
,
hasSemantics
(
expect
(
semantics
,
hasSemantics
(
new
TestSemantics
.
root
(
new
TestSemantics
.
root
(
children:
<
TestSemantics
>[
children:
<
TestSemantics
>[
new
TestSemantics
.
rootChild
(
new
TestSemantics
(
id:
1
,
id:
1
,
label:
'I am text!
\n
Moar text!!1
'
,
label:
'I am text!'
,
textDirection:
TextDirection
.
ltr
,
textDirection:
TextDirection
.
ltr
,
children:
<
TestSemantics
>[
),
new
TestSemantics
(
new
TestSemantics
(
id:
2
,
id:
2
,
label:
'Button'
,
label:
'Moar text!!1'
,
textDirection:
TextDirection
.
ltr
,
textDirection:
TextDirection
.
ltr
,
actions:
<
SemanticsAction
>[
),
SemanticsAction
.
tap
,
new
TestSemantics
(
],
id:
3
,
flags:
<
SemanticsFlag
>[
label:
'Button'
,
SemanticsFlag
.
isButton
,
textDirection:
TextDirection
.
ltr
,
SemanticsFlag
.
hasEnabledState
,
actions:
<
SemanticsAction
>[
SemanticsFlag
.
isEnabled
,
SemanticsAction
.
tap
,
],
),
],
],
flags:
<
SemanticsFlag
>[
SemanticsFlag
.
isButton
,
SemanticsFlag
.
hasEnabledState
,
SemanticsFlag
.
isEnabled
,
],
),
],
),
ignoreTransform:
true
,
ignoreRect:
true
,
));
semantics
.
dispose
();
});
testWidgets
(
'Card merges children when it is a semanticContainer'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
new
SemanticsTester
(
tester
);
debugResetSemanticsIdCounter
();
await
tester
.
pumpWidget
(
new
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
new
Material
(
child:
new
Center
(
child:
new
Card
(
semanticContainer:
true
,
child:
new
Column
(
children:
const
<
Widget
>[
Text
(
'First child'
),
Text
(
'Second child'
)
],
)
),
),
),
),
);
expect
(
semantics
,
hasSemantics
(
new
TestSemantics
.
root
(
children:
<
TestSemantics
>[
new
TestSemantics
(
id:
1
,
label:
'First child
\n
Second child'
,
textDirection:
TextDirection
.
ltr
,
),
),
],
],
),
),
...
...
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