From d9096a42263881ad53890bf774328c2c6f101d67 Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Tue, 12 Mar 2019 09:44:39 -0700 Subject: [PATCH] MaterialButton shape should override ButtonTheme shape (#29189) --- .../lib/src/material/material_button.dart | 5 ++++- .../flutter/test/material/buttons_test.dart | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/material_button.dart b/packages/flutter/lib/src/material/material_button.dart index 65b46d9c75..3278a08d71 100644 --- a/packages/flutter/lib/src/material/material_button.dart +++ b/packages/flutter/lib/src/material/material_button.dart @@ -223,6 +223,9 @@ class MaterialButton extends StatelessWidget { /// The button's highlight and splash are clipped to this shape. If the /// button has an elevation, then its drop shadow is defined by this /// shape as well. + /// + /// Defaults to the value from the current [ButtonTheme], + /// [ButtonThemeData.shape]. final ShapeBorder shape; /// {@macro flutter.widgets.Clip} @@ -271,7 +274,7 @@ class MaterialButton extends StatelessWidget { minWidth: minWidth, minHeight: height, ), - shape: buttonTheme.shape, + shape: buttonTheme.getShape(this), clipBehavior: clipBehavior ?? Clip.none, animationDuration: buttonTheme.getAnimationDuration(this), child: child, diff --git a/packages/flutter/test/material/buttons_test.dart b/packages/flutter/test/material/buttons_test.dart index a930d76de2..03312c86ad 100644 --- a/packages/flutter/test/material/buttons_test.dart +++ b/packages/flutter/test/material/buttons_test.dart @@ -625,4 +625,24 @@ void main() { paintsExactlyCountTimes(#clipPath, 0), ); }); + + testWidgets('MaterialButton shape overrides ButtonTheme shape', (WidgetTester tester) async { + // Regression test for https://github.com/flutter/flutter/issues/29146 + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: MaterialButton( + onPressed: () { }, + shape: const StadiumBorder(), + child: const Text('button'), + ), + ), + ); + + final Finder rawButtonMaterial = find.descendant( + of: find.byType(MaterialButton), + matching: find.byType(Material), + ); + expect(tester.widget(rawButtonMaterial).shape, const StadiumBorder()); + }); }