diff --git a/packages/flutter/lib/src/cupertino/button.dart b/packages/flutter/lib/src/cupertino/button.dart index 4e929daab5..48385c39c3 100644 --- a/packages/flutter/lib/src/cupertino/button.dart +++ b/packages/flutter/lib/src/cupertino/button.dart @@ -131,15 +131,14 @@ class CupertinoButton extends StatefulWidget { /// Creates an iOS-style button with a filled background. /// - /// The background color is derived from the [CupertinoTheme]'s `primaryColor`. - /// - /// To specify a custom background color, use the [color] argument of the - /// default constructor. + /// The background color is derived from the [color] argument. + /// The foreground color is the [CupertinoTheme]'s `primaryContrastingColor`. const CupertinoButton.filled({ super.key, required this.child, this.sizeStyle = CupertinoButtonSize.large, this.padding, + this.color, this.disabledColor = CupertinoColors.tertiarySystemFill, @Deprecated( 'Use minimumSize instead. ' @@ -158,7 +157,6 @@ class CupertinoButton extends StatefulWidget { required this.onPressed, }) : assert(pressedOpacity == null || (pressedOpacity >= 0.0 && pressedOpacity <= 1.0)), assert(minimumSize == null || minSize == null), - color = null, _style = _CupertinoButtonStyle.filled; /// The widget below this widget in the tree. diff --git a/packages/flutter/test/cupertino/button_test.dart b/packages/flutter/test/cupertino/button_test.dart index c08d800377..db7ac35ee0 100644 --- a/packages/flutter/test/cupertino/button_test.dart +++ b/packages/flutter/test/cupertino/button_test.dart @@ -595,6 +595,33 @@ void main() { .decoration as BoxDecoration; expect(decoration.color, isSameColorAs(CupertinoColors.systemBlue.darkColor)); + + await tester.pumpWidget( + CupertinoApp( + home: CupertinoButton.filled( + color: CupertinoColors.systemRed, + onPressed: () {}, + child: Builder( + builder: (BuildContext context) { + textStyle = DefaultTextStyle.of(context).style; + return const Placeholder(); + }, + ), + ), + ), + ); + + decoration = + tester + .widget( + find.descendant( + of: find.byType(CupertinoButton), + matching: find.byType(DecoratedBox), + ), + ) + .decoration + as BoxDecoration; + expect(decoration.color, isSameColorAs(CupertinoColors.systemRed)); }); testWidgets("All CupertinoButton const maps keys' match the available style sizes", (