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
2b16202e
Unverified
Commit
2b16202e
authored
Feb 12, 2020
by
Josh Burton
Committed by
GitHub
Feb 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds shadowColor property to the Card widget (#47273)
parent
c03fbada
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
1 deletion
+57
-1
card.dart
packages/flutter/lib/src/material/card.dart
+9
-0
card_theme.dart
packages/flutter/lib/src/material/card_theme.dart
+12
-0
card_test.dart
packages/flutter/test/material/card_test.dart
+34
-1
card_theme_test.dart
packages/flutter/test/material/card_theme_test.dart
+2
-0
No files found.
packages/flutter/lib/src/material/card.dart
View file @
2b16202e
...
...
@@ -5,6 +5,7 @@
import
'package:flutter/widgets.dart'
;
import
'card_theme.dart'
;
import
'colors.dart'
;
import
'material.dart'
;
import
'theme.dart'
;
...
...
@@ -101,6 +102,7 @@ class Card extends StatelessWidget {
const
Card
({
Key
key
,
this
.
color
,
this
.
shadowColor
,
this
.
elevation
,
this
.
shape
,
this
.
borderOnForeground
=
true
,
...
...
@@ -120,6 +122,12 @@ class Card extends StatelessWidget {
/// if that's null then [ThemeData.cardColor] is used.
final
Color
color
;
/// The color to paint the shadow below the card.
///
/// If null then the ambient [CardTheme]'s shadowColor is used.
/// If that's null too, then the default is fully opaque black.
final
Color
shadowColor
;
/// The z-coordinate at which to place this card. This controls the size of
/// the shadow below the card.
///
...
...
@@ -189,6 +197,7 @@ class Card extends StatelessWidget {
margin:
margin
??
cardTheme
.
margin
??
const
EdgeInsets
.
all
(
4.0
),
child:
Material
(
type:
MaterialType
.
card
,
shadowColor:
shadowColor
??
cardTheme
.
shadowColor
??
Colors
.
black
,
color:
color
??
cardTheme
.
color
??
Theme
.
of
(
context
).
cardColor
,
elevation:
elevation
??
cardTheme
.
elevation
??
_defaultElevation
,
shape:
shape
??
cardTheme
.
shape
??
const
RoundedRectangleBorder
(
...
...
packages/flutter/lib/src/material/card_theme.dart
View file @
2b16202e
...
...
@@ -34,6 +34,7 @@ class CardTheme extends Diagnosticable {
const
CardTheme
({
this
.
clipBehavior
,
this
.
color
,
this
.
shadowColor
,
this
.
elevation
,
this
.
margin
,
this
.
shape
,
...
...
@@ -49,6 +50,11 @@ class CardTheme extends Diagnosticable {
/// If null, [Card] uses [ThemeData.cardColor].
final
Color
color
;
/// Default value for [Card.shadowColor].
///
/// If null, [Card] defaults to fully opaque black.
final
Color
shadowColor
;
/// Default value for [Card.elevation].
///
/// If null, [Card] uses a default of 1.0.
...
...
@@ -71,6 +77,7 @@ class CardTheme extends Diagnosticable {
CardTheme
copyWith
({
Clip
clipBehavior
,
Color
color
,
Color
shadowColor
,
double
elevation
,
EdgeInsetsGeometry
margin
,
ShapeBorder
shape
,
...
...
@@ -78,6 +85,7 @@ class CardTheme extends Diagnosticable {
return
CardTheme
(
clipBehavior:
clipBehavior
??
this
.
clipBehavior
,
color:
color
??
this
.
color
,
shadowColor:
shadowColor
??
this
.
shadowColor
,
elevation:
elevation
??
this
.
elevation
,
margin:
margin
??
this
.
margin
,
shape:
shape
??
this
.
shape
,
...
...
@@ -99,6 +107,7 @@ class CardTheme extends Diagnosticable {
return
CardTheme
(
clipBehavior:
t
<
0.5
?
a
?.
clipBehavior
:
b
?.
clipBehavior
,
color:
Color
.
lerp
(
a
?.
color
,
b
?.
color
,
t
),
shadowColor:
Color
.
lerp
(
a
?.
shadowColor
,
b
?.
shadowColor
,
t
),
elevation:
lerpDouble
(
a
?.
elevation
,
b
?.
elevation
,
t
),
margin:
EdgeInsetsGeometry
.
lerp
(
a
?.
margin
,
b
?.
margin
,
t
),
shape:
ShapeBorder
.
lerp
(
a
?.
shape
,
b
?.
shape
,
t
),
...
...
@@ -110,6 +119,7 @@ class CardTheme extends Diagnosticable {
return
hashValues
(
clipBehavior
,
color
,
shadowColor
,
elevation
,
margin
,
shape
,
...
...
@@ -125,6 +135,7 @@ class CardTheme extends Diagnosticable {
return
other
is
CardTheme
&&
other
.
clipBehavior
==
clipBehavior
&&
other
.
color
==
color
&&
other
.
shadowColor
==
shadowColor
&&
other
.
elevation
==
elevation
&&
other
.
margin
==
margin
&&
other
.
shape
==
shape
;
...
...
@@ -135,6 +146,7 @@ class CardTheme extends Diagnosticable {
super
.
debugFillProperties
(
properties
);
properties
.
add
(
DiagnosticsProperty
<
Clip
>(
'clipBehavior'
,
clipBehavior
,
defaultValue:
null
));
properties
.
add
(
ColorProperty
(
'color'
,
color
,
defaultValue:
null
));
properties
.
add
(
ColorProperty
(
'shadowColor'
,
shadowColor
,
defaultValue:
null
));
properties
.
add
(
DiagnosticsProperty
<
double
>(
'elevation'
,
elevation
,
defaultValue:
null
));
properties
.
add
(
DiagnosticsProperty
<
EdgeInsetsGeometry
>(
'margin'
,
margin
,
defaultValue:
null
));
properties
.
add
(
DiagnosticsProperty
<
ShapeBorder
>(
'shape'
,
shape
,
defaultValue:
null
));
...
...
packages/flutter/test/material/card_test.dart
View file @
2b16202e
...
...
@@ -188,4 +188,37 @@ void main() {
}));
expect
(
tester
.
widget
<
Material
>(
find
.
byType
(
Material
)).
clipBehavior
,
Clip
.
antiAliasWithSaveLayer
);
});
}
testWidgets
(
'Card shadowColor'
,
(
WidgetTester
tester
)
async
{
Material
_getCardMaterial
(
WidgetTester
tester
)
{
return
tester
.
widget
<
Material
>(
find
.
descendant
(
of:
find
.
byType
(
Card
),
matching:
find
.
byType
(
Material
),
),
);
}
Card
_getCard
(
WidgetTester
tester
)
{
return
tester
.
widget
<
Card
>(
find
.
byType
(
Card
)
);
}
await
tester
.
pumpWidget
(
const
Card
(),
);
expect
(
_getCard
(
tester
).
shadowColor
,
null
);
expect
(
_getCardMaterial
(
tester
).
shadowColor
,
const
Color
(
0xFF000000
));
await
tester
.
pumpWidget
(
const
Card
(
shadowColor:
Colors
.
red
,
),
);
expect
(
_getCardMaterial
(
tester
).
shadowColor
,
_getCard
(
tester
).
shadowColor
);
expect
(
_getCardMaterial
(
tester
).
shadowColor
,
Colors
.
red
);
});
}
\ No newline at end of file
packages/flutter/test/material/card_theme_test.dart
View file @
2b16202e
...
...
@@ -46,6 +46,7 @@ void main() {
expect
(
material
.
clipBehavior
,
cardTheme
.
clipBehavior
);
expect
(
material
.
color
,
cardTheme
.
color
);
expect
(
material
.
shadowColor
,
cardTheme
.
shadowColor
);
expect
(
material
.
elevation
,
cardTheme
.
elevation
);
expect
(
container
.
margin
,
cardTheme
.
margin
);
expect
(
material
.
shape
,
cardTheme
.
shape
);
...
...
@@ -146,6 +147,7 @@ CardTheme _cardTheme() {
return
const
CardTheme
(
clipBehavior:
Clip
.
antiAlias
,
color:
Colors
.
green
,
shadowColor:
Colors
.
red
,
elevation:
6.0
,
margin:
EdgeInsets
.
all
(
7.0
),
shape:
RoundedRectangleBorder
(
...
...
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