diff --git a/packages/flutter/lib/src/material/elevated_button.dart b/packages/flutter/lib/src/material/elevated_button.dart index 472f9b50af..11b4d70c52 100644 --- a/packages/flutter/lib/src/material/elevated_button.dart +++ b/packages/flutter/lib/src/material/elevated_button.dart @@ -229,7 +229,7 @@ class ElevatedButton extends ButtonStyleButton { /// * `2 < textScaleFactor <= 3` - lerp(horizontal(8), horizontal(4)) /// * `3 < textScaleFactor` - horizontal(4) /// * `minimumSize` - Size(64, 36) - /// * `side` - BorderSide.none + /// * `side` - null /// * `shape` - RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)) /// * `mouseCursor` /// * disabled - SystemMouseCursors.forbidden @@ -246,6 +246,11 @@ class ElevatedButton extends ButtonStyleButton { /// * `1 < textScaleFactor <= 2` - lerp(start(12) end(16), horizontal(8)) /// * `2 < textScaleFactor <= 3` - lerp(horizontal(8), horizontal(4)) /// * `3 < textScaleFactor` - horizontal(4) + /// + /// The default value for `side`, which defines the appearance of the button's + /// outline, is null. That means that the outline is defined by the button + /// shape's [OutlinedBorder.side]. Typically the default value of an + /// [OutlinedBorder]'s side is [BorderSide.none], so an outline is not drawn. @override ButtonStyle defaultStyleOf(BuildContext context) { final ThemeData theme = Theme.of(context); @@ -267,7 +272,7 @@ class ElevatedButton extends ButtonStyleButton { textStyle: theme.textTheme.button, padding: scaledPadding, minimumSize: const Size(64, 36), - side: BorderSide.none, + side: null, shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4))), enabledMouseCursor: SystemMouseCursors.click, disabledMouseCursor: SystemMouseCursors.forbidden, diff --git a/packages/flutter/lib/src/material/text_button.dart b/packages/flutter/lib/src/material/text_button.dart index a0faa22d3d..93790f8a60 100644 --- a/packages/flutter/lib/src/material/text_button.dart +++ b/packages/flutter/lib/src/material/text_button.dart @@ -217,7 +217,7 @@ class TextButton extends ButtonStyleButton { /// * `2 < textScaleFactor <= 3` - lerp(horizontal(8), horizontal(4)) /// * `3 < textScaleFactor` - horizontal(4) /// * `minimumSize` - Size(64, 36) - /// * `side` - BorderSide.none + /// * `side` - null /// * `shape` - RoundedRectangleBorder(borderRadius: BorderRadius.circular(4)) /// * `mouseCursor` /// * disabled - SystemMouseCursors.forbidden @@ -233,6 +233,11 @@ class TextButton extends ButtonStyleButton { /// * `textScaleFactor <= 1` - all(8) /// * `1 < textScaleFactor <= 2 `- lerp(all(8), horizontal(4)) /// * `2 < textScaleFactor` - horizontal(4) + /// + /// The default value for `side`, which defines the appearance of the button's + /// outline, is null. That means that the outline is defined by the button + /// shape's [OutlinedBorder.side]. Typically the default value of an + /// [OutlinedBorder]'s side is [BorderSide.none], so an outline is not drawn. @override ButtonStyle defaultStyleOf(BuildContext context) { final ThemeData theme = Theme.of(context); @@ -254,7 +259,7 @@ class TextButton extends ButtonStyleButton { textStyle: theme.textTheme.button, padding: scaledPadding, minimumSize: const Size(64, 36), - side: BorderSide.none, + side: null, shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4))), enabledMouseCursor: SystemMouseCursors.click, disabledMouseCursor: SystemMouseCursors.forbidden, diff --git a/packages/flutter/test/material/elevated_button_test.dart b/packages/flutter/test/material/elevated_button_test.dart index c4436a90e7..7212384d37 100644 --- a/packages/flutter/test/material/elevated_button_test.dart +++ b/packages/flutter/test/material/elevated_button_test.dart @@ -1011,6 +1011,31 @@ void main() { expect(physicalShape().elevation, 0); expect(physicalShape().color, disabledBackgroundColor); }); + + testWidgets('By default, ElevatedButton shape outline is defined by shape.side', (WidgetTester tester) async { + // This is a regression test for https://github.com/flutter/flutter/issues/69544 + + const Color borderColor = Color(0xff4caf50); + await tester.pumpWidget( + MaterialApp( + theme: ThemeData.from(colorScheme: const ColorScheme.light()), + home: Center( + child: ElevatedButton( + style: ElevatedButton.styleFrom( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + side: const BorderSide(width: 4, color: borderColor), + ), + ), + onPressed: () { }, + child: const Text('button'), + ), + ), + ), + ); + + expect(find.byType(ElevatedButton), paints ..path(strokeWidth: 4) ..drrect(color: borderColor)); + }); } TextStyle _iconStyle(WidgetTester tester, IconData icon) {