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
b8629bab
Unverified
Commit
b8629bab
authored
Apr 04, 2018
by
Hans Muller
Committed by
GitHub
Apr 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made Card's margin configurable (#16203)
parent
6c896ae1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
1 deletion
+57
-1
card.dart
packages/flutter/lib/src/material/card.dart
+10
-1
card_test.dart
packages/flutter/test/material/card_test.dart
+47
-0
No files found.
packages/flutter/lib/src/material/card.dart
View file @
b8629bab
...
...
@@ -65,6 +65,7 @@ class Card extends StatelessWidget {
this
.
color
,
this
.
elevation
,
this
.
shape
,
this
.
margin
:
const
EdgeInsets
.
all
(
4.0
),
this
.
child
,
})
:
super
(
key:
key
);
...
...
@@ -91,6 +92,14 @@ class Card extends StatelessWidget {
/// radius of 4.0.
final
ShapeBorder
shape
;
/// The empty space that surrounds the card.
///
/// Defines the card's outer [Container.margin].
///
/// The default margin is 4.0 logical pixels on all sides:
/// `EdgeInsets.all(4.0)`.
final
EdgeInsetsGeometry
margin
;
/// The widget below this widget in the tree.
///
/// {@macro flutter.widgets.child}
...
...
@@ -101,7 +110,7 @@ class Card extends StatelessWidget {
return
new
Semantics
(
container:
true
,
child:
new
Container
(
margin:
const
EdgeInsets
.
all
(
4.0
),
margin:
margin
??
const
EdgeInsets
.
all
(
4.0
),
child:
new
Material
(
type:
MaterialType
.
card
,
color:
color
??
Theme
.
of
(
context
).
cardColor
,
...
...
packages/flutter/test/material/card_test.dart
View file @
b8629bab
...
...
@@ -68,4 +68,51 @@ void main() {
semantics
.
dispose
();
});
testWidgets
(
'Card margin'
,
(
WidgetTester
tester
)
async
{
const
Key
contentsKey
=
const
ValueKey
<
String
>(
'contents'
);
await
tester
.
pumpWidget
(
new
Container
(
alignment:
Alignment
.
topLeft
,
child:
new
Card
(
child:
new
Container
(
key:
contentsKey
,
color:
const
Color
(
0xFF00FF00
),
width:
100.0
,
height:
100.0
,
),
),
),
);
// Default margin is 4
expect
(
tester
.
getTopLeft
(
find
.
byType
(
Card
)),
const
Offset
(
0.0
,
0.0
));
expect
(
tester
.
getSize
(
find
.
byType
(
Card
)),
const
Size
(
108.0
,
108.0
));
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
contentsKey
)),
const
Offset
(
4.0
,
4.0
));
expect
(
tester
.
getSize
(
find
.
byKey
(
contentsKey
)),
const
Size
(
100.0
,
100.0
));
await
tester
.
pumpWidget
(
new
Container
(
alignment:
Alignment
.
topLeft
,
child:
new
Card
(
margin:
EdgeInsets
.
zero
,
child:
new
Container
(
key:
contentsKey
,
color:
const
Color
(
0xFF00FF00
),
width:
100.0
,
height:
100.0
,
),
),
),
);
// Specified margin is zero
expect
(
tester
.
getTopLeft
(
find
.
byType
(
Card
)),
const
Offset
(
0.0
,
0.0
));
expect
(
tester
.
getSize
(
find
.
byType
(
Card
)),
const
Size
(
100.0
,
100.0
));
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
contentsKey
)),
const
Offset
(
0.0
,
0.0
));
expect
(
tester
.
getSize
(
find
.
byKey
(
contentsKey
)),
const
Size
(
100.0
,
100.0
));
});
}
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