From ce51e71d19eeadaa079d70388a61f7ae710313f7 Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Thu, 30 Aug 2018 10:09:44 -0700 Subject: [PATCH] Add Card clipBehavior pass-through property (#21187) --- packages/flutter/lib/src/material/card.dart | 7 +++++++ packages/flutter/test/material/card_test.dart | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/packages/flutter/lib/src/material/card.dart b/packages/flutter/lib/src/material/card.dart index b41e9c2a2b..147bc8454c 100644 --- a/packages/flutter/lib/src/material/card.dart +++ b/packages/flutter/lib/src/material/card.dart @@ -60,12 +60,15 @@ import 'theme.dart'; /// * 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, ), ), diff --git a/packages/flutter/test/material/card_test.dart b/packages/flutter/test/material/card_test.dart index 33eae2e4ba..cbb84cfb8f 100644 --- a/packages/flutter/test/material/card_test.dart +++ b/packages/flutter/test/material/card_test.dart @@ -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(find.byType(Material)).clipBehavior, Clip.none); + + await tester.pumpWidget(const Card(clipBehavior: Clip.antiAlias)); + expect(tester.widget(find.byType(Material)).clipBehavior, Clip.antiAlias); + }); }