Add color to CupertinoButton.filled constructor (#161660)
Issue: https://github.com/flutter/flutter/issues/161590 This pull request adds `color` argument for CupertinoButton.filled constructor --------- Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
This commit is contained in:
parent
4bc1994dde
commit
72540c8a1a
@ -131,15 +131,14 @@ class CupertinoButton extends StatefulWidget {
|
|||||||
|
|
||||||
/// Creates an iOS-style button with a filled background.
|
/// Creates an iOS-style button with a filled background.
|
||||||
///
|
///
|
||||||
/// The background color is derived from the [CupertinoTheme]'s `primaryColor`.
|
/// The background color is derived from the [color] argument.
|
||||||
///
|
/// The foreground color is the [CupertinoTheme]'s `primaryContrastingColor`.
|
||||||
/// To specify a custom background color, use the [color] argument of the
|
|
||||||
/// default constructor.
|
|
||||||
const CupertinoButton.filled({
|
const CupertinoButton.filled({
|
||||||
super.key,
|
super.key,
|
||||||
required this.child,
|
required this.child,
|
||||||
this.sizeStyle = CupertinoButtonSize.large,
|
this.sizeStyle = CupertinoButtonSize.large,
|
||||||
this.padding,
|
this.padding,
|
||||||
|
this.color,
|
||||||
this.disabledColor = CupertinoColors.tertiarySystemFill,
|
this.disabledColor = CupertinoColors.tertiarySystemFill,
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
'Use minimumSize instead. '
|
'Use minimumSize instead. '
|
||||||
@ -158,7 +157,6 @@ class CupertinoButton extends StatefulWidget {
|
|||||||
required this.onPressed,
|
required this.onPressed,
|
||||||
}) : assert(pressedOpacity == null || (pressedOpacity >= 0.0 && pressedOpacity <= 1.0)),
|
}) : assert(pressedOpacity == null || (pressedOpacity >= 0.0 && pressedOpacity <= 1.0)),
|
||||||
assert(minimumSize == null || minSize == null),
|
assert(minimumSize == null || minSize == null),
|
||||||
color = null,
|
|
||||||
_style = _CupertinoButtonStyle.filled;
|
_style = _CupertinoButtonStyle.filled;
|
||||||
|
|
||||||
/// The widget below this widget in the tree.
|
/// The widget below this widget in the tree.
|
||||||
|
@ -595,6 +595,33 @@ void main() {
|
|||||||
.decoration
|
.decoration
|
||||||
as BoxDecoration;
|
as BoxDecoration;
|
||||||
expect(decoration.color, isSameColorAs(CupertinoColors.systemBlue.darkColor));
|
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<DecoratedBox>(
|
||||||
|
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", (
|
testWidgets("All CupertinoButton const maps keys' match the available style sizes", (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user