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

MaterialButton shape should override ButtonTheme shape (#29189)

parent c4ffbb5e
......@@ -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,
......
......@@ -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<Material>(rawButtonMaterial).shape, const StadiumBorder());
});
}
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