Unverified Commit ce51e71d authored by Hans Muller's avatar Hans Muller Committed by GitHub

Add Card clipBehavior pass-through property (#21187)

parent ec5c2e3e
......@@ -60,12 +60,15 @@ import 'theme.dart';
/// * <https://material.google.com/components/cards.html>
class Card extends StatelessWidget {
/// Creates a material design card.
///
/// The [clipBehavior] argument must not be null.
const Card({
Key key,
this.color,
this.elevation,
this.shape,
this.margin = const EdgeInsets.all(4.0),
this.clipBehavior = Clip.none,
this.child,
this.semanticContainer = true,
}) : super(key: key);
......@@ -93,6 +96,9 @@ class Card extends StatelessWidget {
/// radius of 4.0.
final ShapeBorder shape;
/// {@macro flutter.widgets.Clip}
final Clip clipBehavior;
/// The empty space that surrounds the card.
///
/// Defines the card's outer [Container.margin].
......@@ -133,6 +139,7 @@ class Card extends StatelessWidget {
shape: shape ?? const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4.0)),
),
clipBehavior: clipBehavior,
child: child,
),
),
......
......@@ -157,4 +157,11 @@ void main() {
expect(tester.getSize(find.byKey(contentsKey)), const Size(100.0, 100.0));
});
testWidgets('Card clipBehavior property passes through to the Material', (WidgetTester tester) async {
await tester.pumpWidget(const Card());
expect(tester.widget<Material>(find.byType(Material)).clipBehavior, Clip.none);
await tester.pumpWidget(const Card(clipBehavior: Clip.antiAlias));
expect(tester.widget<Material>(find.byType(Material)).clipBehavior, Clip.antiAlias);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment