MaterialButton shape should override ButtonTheme shape (#29189)
This commit is contained in:
@@ -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());
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user