Add Card clipBehavior pass-through property (#21187)
diff --git a/packages/flutter/lib/src/material/card.dart b/packages/flutter/lib/src/material/card.dart
index b41e9c2..147bc84 100644
--- a/packages/flutter/lib/src/material/card.dart
+++ b/packages/flutter/lib/src/material/card.dart
@@ -60,12 +60,15 @@
/// * <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 @@
/// 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 @@
shape: shape ?? const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4.0)),
),
+ clipBehavior: clipBehavior,
child: child,
),
),
diff --git a/packages/flutter/test/material/card_test.dart b/packages/flutter/test/material/card_test.dart
index 33eae2e..cbb84cf 100644
--- a/packages/flutter/test/material/card_test.dart
+++ b/packages/flutter/test/material/card_test.dart
@@ -157,4 +157,11 @@
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);
+ });
}