Unverified Commit 17e2fce1 authored by Darren Austin's avatar Darren Austin Committed by GitHub

Add const `MaterialStatePropertyAll` class. (#104127)

parent b1f10ceb
...@@ -64,7 +64,7 @@ class _TokenDefaultsM3 extends ButtonStyle { ...@@ -64,7 +64,7 @@ class _TokenDefaultsM3 extends ButtonStyle {
@override @override
MaterialStateProperty<TextStyle?> get textStyle => MaterialStateProperty<TextStyle?> get textStyle =>
MaterialStateProperty.all<TextStyle?>(${textStyle("$tokenGroup.label-text")}); MaterialStatePropertyAll<TextStyle?>(${textStyle("$tokenGroup.label-text")});
@override @override
MaterialStateProperty<Color?>? get backgroundColor =>${_backgroundColor()}; MaterialStateProperty<Color?>? get backgroundColor =>${_backgroundColor()};
......
...@@ -143,7 +143,7 @@ class ListPage extends StatelessWidget { ...@@ -143,7 +143,7 @@ class ListPage extends StatelessWidget {
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 8), padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 8),
child: OutlinedButton( child: OutlinedButton(
style: buttonStyle.copyWith( style: buttonStyle.copyWith(
backgroundColor: MaterialStateProperty.all<Color>( backgroundColor: MaterialStatePropertyAll<Color>(
Color.lerp(destination.color[100], Colors.white, index / itemCount)! Color.lerp(destination.color[100], Colors.white, index / itemCount)!
), ),
), ),
......
...@@ -101,7 +101,7 @@ class _SaveButtonState extends State<SaveButton> { ...@@ -101,7 +101,7 @@ class _SaveButtonState extends State<SaveButton> {
icon: const Icon(Icons.save), icon: const Icon(Icons.save),
label: Text('$savedValue'), label: Text('$savedValue'),
style: ButtonStyle( style: ButtonStyle(
foregroundColor: MaterialStateProperty.all<Color>( foregroundColor: MaterialStatePropertyAll<Color>(
widget.valueNotifier.value ? Colors.red : Colors.green, widget.valueNotifier.value ? Colors.red : Colors.green,
), ),
), ),
......
...@@ -53,7 +53,7 @@ import 'theme_data.dart'; ...@@ -53,7 +53,7 @@ import 'theme_data.dart';
/// ```dart /// ```dart
/// ElevatedButton( /// ElevatedButton(
/// style: ButtonStyle( /// style: ButtonStyle(
/// backgroundColor: MaterialStateProperty.all<Color>(Colors.green), /// backgroundColor: MaterialStatePropertyAll<Color>(Colors.green),
/// ), /// ),
/// ) /// )
/// ``` /// ```
......
...@@ -148,10 +148,10 @@ abstract class ButtonStyleButton extends StatefulWidget { ...@@ -148,10 +148,10 @@ abstract class ButtonStyleButton extends StatefulWidget {
properties.add(DiagnosticsProperty<FocusNode>('focusNode', focusNode, defaultValue: null)); properties.add(DiagnosticsProperty<FocusNode>('focusNode', focusNode, defaultValue: null));
} }
/// Returns null if [value] is null, otherwise `MaterialStateProperty.all<T>(value)`. /// Returns null if [value] is null, otherwise `MaterialStatePropertyAll<T>(value)`.
/// ///
/// A convenience method for subclasses. /// A convenience method for subclasses.
static MaterialStateProperty<T>? allOrNull<T>(T? value) => value == null ? null : MaterialStateProperty.all<T>(value); static MaterialStateProperty<T>? allOrNull<T>(T? value) => value == null ? null : MaterialStatePropertyAll<T>(value);
/// Returns an interpolated value based on the [textScaleFactor] parameter: /// Returns an interpolated value based on the [textScaleFactor] parameter:
/// ///
......
...@@ -172,7 +172,7 @@ class ElevatedButton extends ButtonStyleButton { ...@@ -172,7 +172,7 @@ class ElevatedButton extends ButtonStyleButton {
: _ElevatedButtonDefaultMouseCursor(enabledMouseCursor, disabledMouseCursor); : _ElevatedButtonDefaultMouseCursor(enabledMouseCursor, disabledMouseCursor);
return ButtonStyle( return ButtonStyle(
textStyle: MaterialStateProperty.all<TextStyle?>(textStyle), textStyle: MaterialStatePropertyAll<TextStyle?>(textStyle),
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
foregroundColor: foregroundColor, foregroundColor: foregroundColor,
overlayColor: overlayColor, overlayColor: overlayColor,
...@@ -468,7 +468,7 @@ class _ElevatedButtonWithIcon extends ElevatedButton { ...@@ -468,7 +468,7 @@ class _ElevatedButtonWithIcon extends ElevatedButton {
MediaQuery.maybeOf(context)?.textScaleFactor ?? 1, MediaQuery.maybeOf(context)?.textScaleFactor ?? 1,
); );
return super.defaultStyleOf(context).copyWith( return super.defaultStyleOf(context).copyWith(
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(scaledPadding), padding: MaterialStatePropertyAll<EdgeInsetsGeometry>(scaledPadding),
); );
} }
} }
...@@ -510,7 +510,7 @@ class _TokenDefaultsM3 extends ButtonStyle { ...@@ -510,7 +510,7 @@ class _TokenDefaultsM3 extends ButtonStyle {
@override @override
MaterialStateProperty<TextStyle?> get textStyle => MaterialStateProperty<TextStyle?> get textStyle =>
MaterialStateProperty.all<TextStyle?>(Theme.of(context).textTheme.labelLarge); MaterialStatePropertyAll<TextStyle?>(Theme.of(context).textTheme.labelLarge);
@override @override
MaterialStateProperty<Color?>? get backgroundColor => MaterialStateProperty<Color?>? get backgroundColor =>
......
...@@ -651,7 +651,13 @@ abstract class MaterialStateProperty<T> { ...@@ -651,7 +651,13 @@ abstract class MaterialStateProperty<T> {
/// Convenience method for creating a [MaterialStateProperty] that resolves /// Convenience method for creating a [MaterialStateProperty] that resolves
/// to a single value for all states. /// to a single value for all states.
static MaterialStateProperty<T> all<T>(T value) => _MaterialStatePropertyAll<T>(value); ///
/// If you need a const value, use [MaterialStatePropertyAll] directly.
///
// TODO(darrenaustin): Deprecate this when we have the ability to create
// a dart fix that will replace this with MaterialStatePropertyAll:
// https://github.com/dart-lang/sdk/issues/49056.
static MaterialStateProperty<T> all<T>(T value) => MaterialStatePropertyAll<T>(value);
} }
class _MaterialStatePropertyWith<T> implements MaterialStateProperty<T> { class _MaterialStatePropertyWith<T> implements MaterialStateProperty<T> {
...@@ -663,14 +669,20 @@ class _MaterialStatePropertyWith<T> implements MaterialStateProperty<T> { ...@@ -663,14 +669,20 @@ class _MaterialStatePropertyWith<T> implements MaterialStateProperty<T> {
T resolve(Set<MaterialState> states) => _resolve(states); T resolve(Set<MaterialState> states) => _resolve(states);
} }
class _MaterialStatePropertyAll<T> implements MaterialStateProperty<T> { /// Convenience class for creating a [MaterialStateProperty] that
_MaterialStatePropertyAll(this.value); /// resolves to the given value for all states.
class MaterialStatePropertyAll<T> implements MaterialStateProperty<T> {
/// Constructs a [MaterialStateProperty] that always resolves to the given
/// value.
const MaterialStatePropertyAll(this.value);
/// The value of the property that will be used for all states.
final T value; final T value;
@override @override
T resolve(Set<MaterialState> states) => value; T resolve(Set<MaterialState> states) => value;
@override @override
String toString() => 'MaterialStateProperty.all($value)'; String toString() => 'MaterialStatePropertyAll($value)';
} }
...@@ -1194,7 +1194,7 @@ class _Defaults extends NavigationBarThemeData { ...@@ -1194,7 +1194,7 @@ class _Defaults extends NavigationBarThemeData {
@override Color? get backgroundColor => ElevationOverlay.colorWithOverlay(_colors.surface, _colors.onSurface, 3.0); @override Color? get backgroundColor => ElevationOverlay.colorWithOverlay(_colors.surface, _colors.onSurface, 3.0);
@override MaterialStateProperty<IconThemeData?>? get iconTheme { @override MaterialStateProperty<IconThemeData?>? get iconTheme {
return MaterialStateProperty.all(IconThemeData( return MaterialStatePropertyAll<IconThemeData>(IconThemeData(
size: 24, size: 24,
color: _colors.onSurface, color: _colors.onSurface,
)); ));
...@@ -1202,7 +1202,7 @@ class _Defaults extends NavigationBarThemeData { ...@@ -1202,7 +1202,7 @@ class _Defaults extends NavigationBarThemeData {
@override Color? get indicatorColor => _colors.secondary.withOpacity(0.24); @override Color? get indicatorColor => _colors.secondary.withOpacity(0.24);
@override MaterialStateProperty<TextStyle?>? get labelTextStyle => MaterialStateProperty.all(_theme.textTheme.overline!.copyWith(color: _colors.onSurface)); @override MaterialStateProperty<TextStyle?>? get labelTextStyle => MaterialStatePropertyAll<TextStyle?>(_theme.textTheme.overline!.copyWith(color: _colors.onSurface));
} }
// BEGIN GENERATED TOKEN PROPERTIES // BEGIN GENERATED TOKEN PROPERTIES
......
...@@ -433,7 +433,7 @@ class _TokenDefaultsM3 extends ButtonStyle { ...@@ -433,7 +433,7 @@ class _TokenDefaultsM3 extends ButtonStyle {
@override @override
MaterialStateProperty<TextStyle?> get textStyle => MaterialStateProperty<TextStyle?> get textStyle =>
MaterialStateProperty.all<TextStyle?>(Theme.of(context).textTheme.labelLarge); MaterialStatePropertyAll<TextStyle?>(Theme.of(context).textTheme.labelLarge);
@override @override
MaterialStateProperty<Color?>? get backgroundColor => MaterialStateProperty<Color?>? get backgroundColor =>
......
...@@ -504,8 +504,8 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin { ...@@ -504,8 +504,8 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
backgroundColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) { backgroundColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
return _isDark() || states.contains(MaterialState.disabled) ? null : colorScheme.primary; return _isDark() || states.contains(MaterialState.disabled) ? null : colorScheme.primary;
}), }),
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(buttonPadding), padding: const MaterialStatePropertyAll<EdgeInsetsGeometry>(buttonPadding),
shape: MaterialStateProperty.all<OutlinedBorder>(buttonShape), shape: const MaterialStatePropertyAll<OutlinedBorder>(buttonShape),
), ),
child: Text(localizations.continueButtonLabel), child: Text(localizations.continueButtonLabel),
), ),
......
...@@ -426,7 +426,7 @@ class _TextButtonWithIcon extends TextButton { ...@@ -426,7 +426,7 @@ class _TextButtonWithIcon extends TextButton {
MediaQuery.maybeOf(context)?.textScaleFactor ?? 1, MediaQuery.maybeOf(context)?.textScaleFactor ?? 1,
); );
return super.defaultStyleOf(context).copyWith( return super.defaultStyleOf(context).copyWith(
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(scaledPadding), padding: MaterialStatePropertyAll<EdgeInsetsGeometry>(scaledPadding),
); );
} }
} }
...@@ -471,7 +471,7 @@ class _TokenDefaultsM3 extends ButtonStyle { ...@@ -471,7 +471,7 @@ class _TokenDefaultsM3 extends ButtonStyle {
@override @override
MaterialStateProperty<TextStyle?> get textStyle => MaterialStateProperty<TextStyle?> get textStyle =>
MaterialStateProperty.all<TextStyle?>(Theme.of(context).textTheme.labelLarge); MaterialStatePropertyAll<TextStyle?>(Theme.of(context).textTheme.labelLarge);
@override @override
MaterialStateProperty<Color?>? get backgroundColor => MaterialStateProperty<Color?>? get backgroundColor =>
......
...@@ -742,8 +742,8 @@ class ToggleButtons extends StatelessWidget { ...@@ -742,8 +742,8 @@ class ToggleButtons extends StatelessWidget {
child: TextButton( child: TextButton(
focusNode: focusNodes != null ? focusNodes![index] : null, focusNode: focusNodes != null ? focusNodes![index] : null,
style: ButtonStyle( style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color?>(effectiveFillColor), backgroundColor: MaterialStatePropertyAll<Color?>(effectiveFillColor),
foregroundColor: MaterialStateProperty.all<Color?>(currentColor), foregroundColor: MaterialStatePropertyAll<Color?>(currentColor),
overlayColor: _ToggleButtonDefaultOverlay( overlayColor: _ToggleButtonDefaultOverlay(
selected: onPressed != null && isSelected[index], selected: onPressed != null && isSelected[index],
unselected: onPressed != null && !isSelected[index], unselected: onPressed != null && !isSelected[index],
...@@ -754,15 +754,15 @@ class ToggleButtons extends StatelessWidget { ...@@ -754,15 +754,15 @@ class ToggleButtons extends StatelessWidget {
hoverColor: hoverColor ?? toggleButtonsTheme.hoverColor, hoverColor: hoverColor ?? toggleButtonsTheme.hoverColor,
splashColor: splashColor ?? toggleButtonsTheme.splashColor, splashColor: splashColor ?? toggleButtonsTheme.splashColor,
), ),
elevation: MaterialStateProperty.all<double>(0), elevation: const MaterialStatePropertyAll<double>(0),
textStyle: MaterialStateProperty.all<TextStyle?>(currentTextStyle.copyWith( textStyle: MaterialStatePropertyAll<TextStyle?>(currentTextStyle.copyWith(
color: currentColor, color: currentColor,
)), )),
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(EdgeInsets.zero), padding: const MaterialStatePropertyAll<EdgeInsetsGeometry>(EdgeInsets.zero),
minimumSize: MaterialStateProperty.all<Size?>(minimumSize), minimumSize: MaterialStatePropertyAll<Size?>(minimumSize),
maximumSize: MaterialStateProperty.all<Size?>(maximumSize), maximumSize: MaterialStatePropertyAll<Size?>(maximumSize),
shape: MaterialStateProperty.all<OutlinedBorder>(const RoundedRectangleBorder()), shape: const MaterialStatePropertyAll<OutlinedBorder>(RoundedRectangleBorder()),
mouseCursor: MaterialStateProperty.all<MouseCursor?>(mouseCursor), mouseCursor: MaterialStatePropertyAll<MouseCursor?>(mouseCursor),
visualDensity: VisualDensity.standard, visualDensity: VisualDensity.standard,
tapTargetSize: MaterialTapTargetSize.shrinkWrap, tapTargetSize: MaterialTapTargetSize.shrinkWrap,
animationDuration: kThemeChangeDuration, animationDuration: kThemeChangeDuration,
......
...@@ -50,22 +50,22 @@ void main() { ...@@ -50,22 +50,22 @@ void main() {
testWidgets('ButtonStyle debugFillProperties', (WidgetTester tester) async { testWidgets('ButtonStyle debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
ButtonStyle( const ButtonStyle(
textStyle: MaterialStateProperty.all<TextStyle>(const TextStyle(fontSize: 10.0)), textStyle: MaterialStatePropertyAll<TextStyle>(TextStyle(fontSize: 10.0)),
backgroundColor: MaterialStateProperty.all<Color>(const Color(0xfffffff1)), backgroundColor: MaterialStatePropertyAll<Color>(Color(0xfffffff1)),
foregroundColor: MaterialStateProperty.all<Color>(const Color(0xfffffff2)), foregroundColor: MaterialStatePropertyAll<Color>(Color(0xfffffff2)),
overlayColor: MaterialStateProperty.all<Color>(const Color(0xfffffff3)), overlayColor: MaterialStatePropertyAll<Color>(Color(0xfffffff3)),
shadowColor: MaterialStateProperty.all<Color>(const Color(0xfffffff4)), shadowColor: MaterialStatePropertyAll<Color>(Color(0xfffffff4)),
surfaceTintColor: MaterialStateProperty.all<Color>(const Color(0xfffffff5)), surfaceTintColor: MaterialStatePropertyAll<Color>(Color(0xfffffff5)),
elevation: MaterialStateProperty.all<double>(1.5), elevation: MaterialStatePropertyAll<double>(1.5),
padding: MaterialStateProperty.all<EdgeInsets>(const EdgeInsets.all(1.0)), padding: MaterialStatePropertyAll<EdgeInsets>(EdgeInsets.all(1.0)),
minimumSize: MaterialStateProperty.all<Size>(const Size(1.0, 2.0)), minimumSize: MaterialStatePropertyAll<Size>(Size(1.0, 2.0)),
side: MaterialStateProperty.all<BorderSide>(const BorderSide(width: 4.0, color: Color(0xfffffff6))), side: MaterialStatePropertyAll<BorderSide>(BorderSide(width: 4.0, color: Color(0xfffffff6))),
maximumSize: MaterialStateProperty.all<Size>(const Size(100.0, 200.0)), maximumSize: MaterialStatePropertyAll<Size>(Size(100.0, 200.0)),
shape: MaterialStateProperty.all<OutlinedBorder>(const StadiumBorder()), shape: MaterialStatePropertyAll<OutlinedBorder>(StadiumBorder()),
mouseCursor: MaterialStateProperty.all<MouseCursor>(SystemMouseCursors.forbidden), mouseCursor: MaterialStatePropertyAll<MouseCursor>(SystemMouseCursors.forbidden),
tapTargetSize: MaterialTapTargetSize.shrinkWrap, tapTargetSize: MaterialTapTargetSize.shrinkWrap,
animationDuration: const Duration(seconds: 1), animationDuration: Duration(seconds: 1),
enableFeedback: true, enableFeedback: true,
).debugFillProperties(builder); ).debugFillProperties(builder);
...@@ -75,19 +75,19 @@ void main() { ...@@ -75,19 +75,19 @@ void main() {
.toList(); .toList();
expect(description, <String>[ expect(description, <String>[
'textStyle: MaterialStateProperty.all(TextStyle(inherit: true, size: 10.0))', 'textStyle: MaterialStatePropertyAll(TextStyle(inherit: true, size: 10.0))',
'backgroundColor: MaterialStateProperty.all(Color(0xfffffff1))', 'backgroundColor: MaterialStatePropertyAll(Color(0xfffffff1))',
'foregroundColor: MaterialStateProperty.all(Color(0xfffffff2))', 'foregroundColor: MaterialStatePropertyAll(Color(0xfffffff2))',
'overlayColor: MaterialStateProperty.all(Color(0xfffffff3))', 'overlayColor: MaterialStatePropertyAll(Color(0xfffffff3))',
'shadowColor: MaterialStateProperty.all(Color(0xfffffff4))', 'shadowColor: MaterialStatePropertyAll(Color(0xfffffff4))',
'surfaceTintColor: MaterialStateProperty.all(Color(0xfffffff5))', 'surfaceTintColor: MaterialStatePropertyAll(Color(0xfffffff5))',
'elevation: MaterialStateProperty.all(1.5)', 'elevation: MaterialStatePropertyAll(1.5)',
'padding: MaterialStateProperty.all(EdgeInsets.all(1.0))', 'padding: MaterialStatePropertyAll(EdgeInsets.all(1.0))',
'minimumSize: MaterialStateProperty.all(Size(1.0, 2.0))', 'minimumSize: MaterialStatePropertyAll(Size(1.0, 2.0))',
'maximumSize: MaterialStateProperty.all(Size(100.0, 200.0))', 'maximumSize: MaterialStatePropertyAll(Size(100.0, 200.0))',
'side: MaterialStateProperty.all(BorderSide(Color(0xfffffff6), 4.0, BorderStyle.solid))', 'side: MaterialStatePropertyAll(BorderSide(Color(0xfffffff6), 4.0, BorderStyle.solid))',
'shape: MaterialStateProperty.all(StadiumBorder(BorderSide(Color(0xff000000), 0.0, BorderStyle.none)))', 'shape: MaterialStatePropertyAll(StadiumBorder(BorderSide(Color(0xff000000), 0.0, BorderStyle.none)))',
'mouseCursor: MaterialStateProperty.all(SystemMouseCursor(forbidden))', 'mouseCursor: MaterialStatePropertyAll(SystemMouseCursor(forbidden))',
'tapTargetSize: shrinkWrap', 'tapTargetSize: shrinkWrap',
'animationDuration: 0:00:01.000000', 'animationDuration: 0:00:01.000000',
'enableFeedback: true', 'enableFeedback: true',
...@@ -95,26 +95,26 @@ void main() { ...@@ -95,26 +95,26 @@ void main() {
}); });
testWidgets('ButtonStyle copyWith, merge', (WidgetTester tester) async { testWidgets('ButtonStyle copyWith, merge', (WidgetTester tester) async {
final MaterialStateProperty<TextStyle> textStyle = MaterialStateProperty.all<TextStyle>(const TextStyle(fontSize: 10)); const MaterialStateProperty<TextStyle> textStyle = MaterialStatePropertyAll<TextStyle>(TextStyle(fontSize: 10));
final MaterialStateProperty<Color> backgroundColor = MaterialStateProperty.all<Color>(const Color(0xfffffff1)); const MaterialStateProperty<Color> backgroundColor = MaterialStatePropertyAll<Color>(Color(0xfffffff1));
final MaterialStateProperty<Color> foregroundColor = MaterialStateProperty.all<Color>(const Color(0xfffffff2)); const MaterialStateProperty<Color> foregroundColor = MaterialStatePropertyAll<Color>(Color(0xfffffff2));
final MaterialStateProperty<Color> overlayColor = MaterialStateProperty.all<Color>(const Color(0xfffffff3)); const MaterialStateProperty<Color> overlayColor = MaterialStatePropertyAll<Color>(Color(0xfffffff3));
final MaterialStateProperty<Color> shadowColor = MaterialStateProperty.all<Color>(const Color(0xfffffff4)); const MaterialStateProperty<Color> shadowColor = MaterialStatePropertyAll<Color>(Color(0xfffffff4));
final MaterialStateProperty<Color> surfaceTintColor = MaterialStateProperty.all<Color>(const Color(0xfffffff5)); const MaterialStateProperty<Color> surfaceTintColor = MaterialStatePropertyAll<Color>(Color(0xfffffff5));
final MaterialStateProperty<double> elevation = MaterialStateProperty.all<double>(1); const MaterialStateProperty<double> elevation = MaterialStatePropertyAll<double>(1);
final MaterialStateProperty<EdgeInsets> padding = MaterialStateProperty.all<EdgeInsets>(const EdgeInsets.all(1)); const MaterialStateProperty<EdgeInsets> padding = MaterialStatePropertyAll<EdgeInsets>(EdgeInsets.all(1));
final MaterialStateProperty<Size> minimumSize = MaterialStateProperty.all<Size>(const Size(1, 2)); const MaterialStateProperty<Size> minimumSize = MaterialStatePropertyAll<Size>(Size(1, 2));
final MaterialStateProperty<Size> fixedSize = MaterialStateProperty.all<Size>(const Size(3, 4)); const MaterialStateProperty<Size> fixedSize = MaterialStatePropertyAll<Size>(Size(3, 4));
final MaterialStateProperty<Size> maximumSize = MaterialStateProperty.all<Size>(const Size(5, 6)); const MaterialStateProperty<Size> maximumSize = MaterialStatePropertyAll<Size>(Size(5, 6));
final MaterialStateProperty<BorderSide> side = MaterialStateProperty.all<BorderSide>(const BorderSide()); const MaterialStateProperty<BorderSide> side = MaterialStatePropertyAll<BorderSide>(BorderSide());
final MaterialStateProperty<OutlinedBorder> shape = MaterialStateProperty.all<OutlinedBorder>(const StadiumBorder()); const MaterialStateProperty<OutlinedBorder> shape = MaterialStatePropertyAll<OutlinedBorder>(StadiumBorder());
final MaterialStateProperty<MouseCursor> mouseCursor = MaterialStateProperty.all<MouseCursor>(SystemMouseCursors.forbidden); const MaterialStateProperty<MouseCursor> mouseCursor = MaterialStatePropertyAll<MouseCursor>(SystemMouseCursors.forbidden);
const VisualDensity visualDensity = VisualDensity.compact; const VisualDensity visualDensity = VisualDensity.compact;
const MaterialTapTargetSize tapTargetSize = MaterialTapTargetSize.shrinkWrap; const MaterialTapTargetSize tapTargetSize = MaterialTapTargetSize.shrinkWrap;
const Duration animationDuration = Duration(seconds: 1); const Duration animationDuration = Duration(seconds: 1);
const bool enableFeedback = true; const bool enableFeedback = true;
final ButtonStyle style = ButtonStyle( const ButtonStyle style = ButtonStyle(
textStyle: textStyle, textStyle: textStyle,
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
foregroundColor: foregroundColor, foregroundColor: foregroundColor,
...@@ -180,8 +180,8 @@ void main() { ...@@ -180,8 +180,8 @@ void main() {
const BorderSide whiteSide = BorderSide(color: Color(0xFFFFFFFF)); const BorderSide whiteSide = BorderSide(color: Color(0xFFFFFFFF));
const BorderSide emptyBlackSide = BorderSide(width: 0, color: Color(0x00000000)); const BorderSide emptyBlackSide = BorderSide(width: 0, color: Color(0x00000000));
final ButtonStyle blackStyle = ButtonStyle(side: MaterialStateProperty.all<BorderSide>(blackSide)); const ButtonStyle blackStyle = ButtonStyle(side: MaterialStatePropertyAll<BorderSide>(blackSide));
final ButtonStyle whiteStyle = ButtonStyle(side: MaterialStateProperty.all<BorderSide>(whiteSide)); const ButtonStyle whiteStyle = ButtonStyle(side: MaterialStatePropertyAll<BorderSide>(whiteSide));
// MaterialState.all<Foo>(value) properties resolve to value // MaterialState.all<Foo>(value) properties resolve to value
// for any set of MaterialStates. // for any set of MaterialStates.
......
...@@ -968,7 +968,7 @@ void main() { ...@@ -968,7 +968,7 @@ void main() {
autofocus: focused, autofocus: focused,
value: active, value: active,
onChanged: (_) { }, onChanged: (_) { },
fillColor: MaterialStateProperty.all(fillColor), fillColor: const MaterialStatePropertyAll<Color>(fillColor),
overlayColor: useOverlay ? MaterialStateProperty.resolveWith(getOverlayColor) : null, overlayColor: useOverlay ? MaterialStateProperty.resolveWith(getOverlayColor) : null,
hoverColor: hoverColor, hoverColor: hoverColor,
focusColor: focusColor, focusColor: focusColor,
......
...@@ -49,11 +49,11 @@ void main() { ...@@ -49,11 +49,11 @@ void main() {
testWidgets('CheckboxThemeData implements debugFillProperties', (WidgetTester tester) async { testWidgets('CheckboxThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
CheckboxThemeData( const CheckboxThemeData(
mouseCursor: MaterialStateProperty.all(SystemMouseCursors.click), mouseCursor: MaterialStatePropertyAll<MouseCursor?>(SystemMouseCursors.click),
fillColor: MaterialStateProperty.all(const Color(0xfffffff0)), fillColor: MaterialStatePropertyAll<Color>(Color(0xfffffff0)),
checkColor: MaterialStateProperty.all(const Color(0xfffffff1)), checkColor: MaterialStatePropertyAll<Color>(Color(0xfffffff1)),
overlayColor: MaterialStateProperty.all(const Color(0xfffffff2)), overlayColor: MaterialStatePropertyAll<Color>(Color(0xfffffff2)),
splashRadius: 1.0, splashRadius: 1.0,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
visualDensity: VisualDensity.standard, visualDensity: VisualDensity.standard,
...@@ -64,10 +64,10 @@ void main() { ...@@ -64,10 +64,10 @@ void main() {
.map((DiagnosticsNode node) => node.toString()) .map((DiagnosticsNode node) => node.toString())
.toList(); .toList();
expect(description[0], 'mouseCursor: MaterialStateProperty.all(SystemMouseCursor(click))'); expect(description[0], 'mouseCursor: MaterialStatePropertyAll(SystemMouseCursor(click))');
expect(description[1], 'fillColor: MaterialStateProperty.all(Color(0xfffffff0))'); expect(description[1], 'fillColor: MaterialStatePropertyAll(Color(0xfffffff0))');
expect(description[2], 'checkColor: MaterialStateProperty.all(Color(0xfffffff1))'); expect(description[2], 'checkColor: MaterialStatePropertyAll(Color(0xfffffff1))');
expect(description[3], 'overlayColor: MaterialStateProperty.all(Color(0xfffffff2))'); expect(description[3], 'overlayColor: MaterialStatePropertyAll(Color(0xfffffff2))');
expect(description[4], 'splashRadius: 1.0'); expect(description[4], 'splashRadius: 1.0');
expect(description[5], 'materialTapTargetSize: MaterialTapTargetSize.shrinkWrap'); expect(description[5], 'materialTapTargetSize: MaterialTapTargetSize.shrinkWrap');
expect(description[6], equalsIgnoringHashCodes('visualDensity: VisualDensity#00000(h: 0.0, v: 0.0)')); expect(description[6], equalsIgnoringHashCodes('visualDensity: VisualDensity#00000(h: 0.0, v: 0.0)'));
...@@ -91,7 +91,7 @@ void main() { ...@@ -91,7 +91,7 @@ void main() {
return MaterialApp( return MaterialApp(
theme: ThemeData( theme: ThemeData(
checkboxTheme: CheckboxThemeData( checkboxTheme: CheckboxThemeData(
mouseCursor: MaterialStateProperty.all(mouseCursor), mouseCursor: const MaterialStatePropertyAll<MouseCursor?>(mouseCursor),
fillColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) { fillColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
return selectedFillColor; return selectedFillColor;
...@@ -182,14 +182,14 @@ void main() { ...@@ -182,14 +182,14 @@ void main() {
return MaterialApp( return MaterialApp(
theme: ThemeData( theme: ThemeData(
checkboxTheme: CheckboxThemeData( checkboxTheme: CheckboxThemeData(
mouseCursor: MaterialStateProperty.all(themeMouseCursor), mouseCursor: const MaterialStatePropertyAll<MouseCursor?>(themeMouseCursor),
fillColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) { fillColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
return themeSelectedFillColor; return themeSelectedFillColor;
} }
return themeDefaultFillColor; return themeDefaultFillColor;
}), }),
checkColor: MaterialStateProperty.all(themeCheckColor), checkColor: const MaterialStatePropertyAll<Color?>(themeCheckColor),
overlayColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) { overlayColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
return themeFocusOverlayColor; return themeFocusOverlayColor;
...@@ -361,16 +361,16 @@ void main() { ...@@ -361,16 +361,16 @@ void main() {
Widget buildCheckbox({required bool active}) { Widget buildCheckbox({required bool active}) {
return MaterialApp( return MaterialApp(
theme: ThemeData( theme: ThemeData(
checkboxTheme: CheckboxThemeData( checkboxTheme: const CheckboxThemeData(
checkColor: MaterialStateProperty.all<Color>(globalThemeCheckColor), checkColor: MaterialStatePropertyAll<Color>(globalThemeCheckColor),
fillColor: MaterialStateProperty.all<Color>(globalThemeFillColor), fillColor: MaterialStatePropertyAll<Color>(globalThemeFillColor),
), ),
), ),
home: Scaffold( home: Scaffold(
body: CheckboxTheme( body: CheckboxTheme(
data: CheckboxThemeData( data: const CheckboxThemeData(
fillColor: MaterialStateProperty.all<Color>(localThemeFillColor), fillColor: MaterialStatePropertyAll<Color>(localThemeFillColor),
checkColor: MaterialStateProperty.all<Color>(localThemeCheckColor), checkColor: MaterialStatePropertyAll<Color>(localThemeCheckColor),
), ),
child: Checkbox( child: Checkbox(
value: active, value: active,
......
...@@ -1412,9 +1412,9 @@ void main() { ...@@ -1412,9 +1412,9 @@ void main() {
const Color checkColor = Color(0xFF0000FF); const Color checkColor = Color(0xFF0000FF);
final ThemeData themeData = ThemeData( final ThemeData themeData = ThemeData(
checkboxTheme: CheckboxThemeData( checkboxTheme: const CheckboxThemeData(
fillColor: MaterialStateProperty.all(fillColor), fillColor: MaterialStatePropertyAll<Color?>(fillColor),
checkColor: MaterialStateProperty.all(checkColor), checkColor: MaterialStatePropertyAll<Color?>(checkColor),
), ),
); );
Widget buildTable() { Widget buildTable() {
......
...@@ -92,10 +92,10 @@ void main() { ...@@ -92,10 +92,10 @@ void main() {
testWidgets('DataTable is themeable', (WidgetTester tester) async { testWidgets('DataTable is themeable', (WidgetTester tester) async {
const BoxDecoration decoration = BoxDecoration(color: Color(0xfffffff0)); const BoxDecoration decoration = BoxDecoration(color: Color(0xfffffff0));
final MaterialStateProperty<Color> dataRowColor = MaterialStateProperty.all<Color>(const Color(0xfffffff1)); const MaterialStateProperty<Color> dataRowColor = MaterialStatePropertyAll<Color>(Color(0xfffffff1));
const double dataRowHeight = 51.0; const double dataRowHeight = 51.0;
const TextStyle dataTextStyle = TextStyle(fontSize: 12.5); const TextStyle dataTextStyle = TextStyle(fontSize: 12.5);
final MaterialStateProperty<Color> headingRowColor = MaterialStateProperty.all<Color>(const Color(0xfffffff2)); const MaterialStateProperty<Color> headingRowColor = MaterialStatePropertyAll<Color>(Color(0xfffffff2));
const double headingRowHeight = 52.0; const double headingRowHeight = 52.0;
const TextStyle headingTextStyle = TextStyle(fontSize: 14.5); const TextStyle headingTextStyle = TextStyle(fontSize: 14.5);
const double horizontalMargin = 3.0; const double horizontalMargin = 3.0;
...@@ -105,7 +105,7 @@ void main() { ...@@ -105,7 +105,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData( theme: ThemeData(
dataTableTheme: DataTableThemeData( dataTableTheme: const DataTableThemeData(
decoration: decoration, decoration: decoration,
dataRowColor: dataRowColor, dataRowColor: dataRowColor,
dataRowHeight: dataRowHeight, dataRowHeight: dataRowHeight,
...@@ -159,10 +159,10 @@ void main() { ...@@ -159,10 +159,10 @@ void main() {
testWidgets('DataTable properties are taken over the theme values', (WidgetTester tester) async { testWidgets('DataTable properties are taken over the theme values', (WidgetTester tester) async {
const BoxDecoration themeDecoration = BoxDecoration(color: Color(0xfffffff1)); const BoxDecoration themeDecoration = BoxDecoration(color: Color(0xfffffff1));
final MaterialStateProperty<Color> themeDataRowColor = MaterialStateProperty.all<Color>(const Color(0xfffffff0)); const MaterialStateProperty<Color> themeDataRowColor = MaterialStatePropertyAll<Color>(Color(0xfffffff0));
const double themeDataRowHeight = 50.0; const double themeDataRowHeight = 50.0;
const TextStyle themeDataTextStyle = TextStyle(fontSize: 11.5); const TextStyle themeDataTextStyle = TextStyle(fontSize: 11.5);
final MaterialStateProperty<Color> themeHeadingRowColor = MaterialStateProperty.all<Color>(const Color(0xfffffff1)); const MaterialStateProperty<Color> themeHeadingRowColor = MaterialStatePropertyAll<Color>(Color(0xfffffff1));
const double themeHeadingRowHeight = 51.0; const double themeHeadingRowHeight = 51.0;
const TextStyle themeHeadingTextStyle = TextStyle(fontSize: 13.5); const TextStyle themeHeadingTextStyle = TextStyle(fontSize: 13.5);
const double themeHorizontalMargin = 2.0; const double themeHorizontalMargin = 2.0;
...@@ -170,10 +170,10 @@ void main() { ...@@ -170,10 +170,10 @@ void main() {
const double themeDividerThickness = 4.0; const double themeDividerThickness = 4.0;
const BoxDecoration decoration = BoxDecoration(color: Color(0xfffffff0)); const BoxDecoration decoration = BoxDecoration(color: Color(0xfffffff0));
final MaterialStateProperty<Color> dataRowColor = MaterialStateProperty.all<Color>(const Color(0xfffffff1)); const MaterialStateProperty<Color> dataRowColor = MaterialStatePropertyAll<Color>(Color(0xfffffff1));
const double dataRowHeight = 51.0; const double dataRowHeight = 51.0;
const TextStyle dataTextStyle = TextStyle(fontSize: 12.5); const TextStyle dataTextStyle = TextStyle(fontSize: 12.5);
final MaterialStateProperty<Color> headingRowColor = MaterialStateProperty.all<Color>(const Color(0xfffffff2)); const MaterialStateProperty<Color> headingRowColor = MaterialStatePropertyAll<Color>(Color(0xfffffff2));
const double headingRowHeight = 52.0; const double headingRowHeight = 52.0;
const TextStyle headingTextStyle = TextStyle(fontSize: 14.5); const TextStyle headingTextStyle = TextStyle(fontSize: 14.5);
const double horizontalMargin = 3.0; const double horizontalMargin = 3.0;
...@@ -182,7 +182,7 @@ void main() { ...@@ -182,7 +182,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData( theme: ThemeData(
dataTableTheme: DataTableThemeData( dataTableTheme: const DataTableThemeData(
decoration: themeDecoration, decoration: themeDecoration,
dataRowColor: themeDataRowColor, dataRowColor: themeDataRowColor,
dataRowHeight: themeDataRowHeight, dataRowHeight: themeDataRowHeight,
...@@ -246,10 +246,10 @@ void main() { ...@@ -246,10 +246,10 @@ void main() {
testWidgets('Local DataTableTheme can override global DataTableTheme', (WidgetTester tester) async { testWidgets('Local DataTableTheme can override global DataTableTheme', (WidgetTester tester) async {
const BoxDecoration globalThemeDecoration = BoxDecoration(color: Color(0xfffffff1)); const BoxDecoration globalThemeDecoration = BoxDecoration(color: Color(0xfffffff1));
final MaterialStateProperty<Color> globalThemeDataRowColor = MaterialStateProperty.all<Color>(const Color(0xfffffff0)); const MaterialStateProperty<Color> globalThemeDataRowColor = MaterialStatePropertyAll<Color>(Color(0xfffffff0));
const double globalThemeDataRowHeight = 50.0; const double globalThemeDataRowHeight = 50.0;
const TextStyle globalThemeDataTextStyle = TextStyle(fontSize: 11.5); const TextStyle globalThemeDataTextStyle = TextStyle(fontSize: 11.5);
final MaterialStateProperty<Color> globalThemeHeadingRowColor = MaterialStateProperty.all<Color>(const Color(0xfffffff1)); const MaterialStateProperty<Color> globalThemeHeadingRowColor = MaterialStatePropertyAll<Color>(Color(0xfffffff1));
const double globalThemeHeadingRowHeight = 51.0; const double globalThemeHeadingRowHeight = 51.0;
const TextStyle globalThemeHeadingTextStyle = TextStyle(fontSize: 13.5); const TextStyle globalThemeHeadingTextStyle = TextStyle(fontSize: 13.5);
const double globalThemeHorizontalMargin = 2.0; const double globalThemeHorizontalMargin = 2.0;
...@@ -257,10 +257,10 @@ void main() { ...@@ -257,10 +257,10 @@ void main() {
const double globalThemeDividerThickness = 4.0; const double globalThemeDividerThickness = 4.0;
const BoxDecoration localThemeDecoration = BoxDecoration(color: Color(0xfffffff0)); const BoxDecoration localThemeDecoration = BoxDecoration(color: Color(0xfffffff0));
final MaterialStateProperty<Color> localThemeDataRowColor = MaterialStateProperty.all<Color>(const Color(0xfffffff1)); const MaterialStateProperty<Color> localThemeDataRowColor = MaterialStatePropertyAll<Color>(Color(0xfffffff1));
const double localThemeDataRowHeight = 51.0; const double localThemeDataRowHeight = 51.0;
const TextStyle localThemeDataTextStyle = TextStyle(fontSize: 12.5); const TextStyle localThemeDataTextStyle = TextStyle(fontSize: 12.5);
final MaterialStateProperty<Color> localThemeHeadingRowColor = MaterialStateProperty.all<Color>(const Color(0xfffffff2)); const MaterialStateProperty<Color> localThemeHeadingRowColor = MaterialStatePropertyAll<Color>(Color(0xfffffff2));
const double localThemeHeadingRowHeight = 52.0; const double localThemeHeadingRowHeight = 52.0;
const TextStyle localThemeHeadingTextStyle = TextStyle(fontSize: 14.5); const TextStyle localThemeHeadingTextStyle = TextStyle(fontSize: 14.5);
const double localThemeHorizontalMargin = 3.0; const double localThemeHorizontalMargin = 3.0;
...@@ -270,7 +270,7 @@ void main() { ...@@ -270,7 +270,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData( theme: ThemeData(
dataTableTheme: DataTableThemeData( dataTableTheme: const DataTableThemeData(
decoration: globalThemeDecoration, decoration: globalThemeDecoration,
dataRowColor: globalThemeDataRowColor, dataRowColor: globalThemeDataRowColor,
dataRowHeight: globalThemeDataRowHeight, dataRowHeight: globalThemeDataRowHeight,
...@@ -285,7 +285,7 @@ void main() { ...@@ -285,7 +285,7 @@ void main() {
), ),
home: Scaffold( home: Scaffold(
body: DataTableTheme( body: DataTableTheme(
data: DataTableThemeData( data: const DataTableThemeData(
decoration: localThemeDecoration, decoration: localThemeDecoration,
dataRowColor: localThemeDataRowColor, dataRowColor: localThemeDataRowColor,
dataRowHeight: localThemeDataRowHeight, dataRowHeight: localThemeDataRowHeight,
......
...@@ -689,11 +689,11 @@ void main() { ...@@ -689,11 +689,11 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Center( child: Center(
child: ElevatedButton( child: ElevatedButton(
style: ButtonStyle( style: const ButtonStyle(
// Specifying minimumSize to mimic the original minimumSize for // Specifying minimumSize to mimic the original minimumSize for
// RaisedButton so that the semantics tree's rect and transform // RaisedButton so that the semantics tree's rect and transform
// match the original version of this test. // match the original version of this test.
minimumSize: MaterialStateProperty.all<Size>(const Size(88, 36)), minimumSize: MaterialStatePropertyAll<Size>(Size(88, 36)),
), ),
onPressed: () { }, onPressed: () { },
child: const Text('ABC'), child: const Text('ABC'),
...@@ -728,11 +728,11 @@ void main() { ...@@ -728,11 +728,11 @@ void main() {
}); });
testWidgets('ElevatedButton size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async { testWidgets('ElevatedButton size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
final ButtonStyle style = ButtonStyle( const ButtonStyle style = ButtonStyle(
// Specifying minimumSize to mimic the original minimumSize for // Specifying minimumSize to mimic the original minimumSize for
// RaisedButton so that the corresponding button size matches // RaisedButton so that the corresponding button size matches
// the original version of this test. // the original version of this test.
minimumSize: MaterialStateProperty.all<Size>(const Size(88, 36)), minimumSize: MaterialStatePropertyAll<Size>(Size(88, 36)),
); );
Widget buildFrame(MaterialTapTargetSize tapTargetSize, Key key) { Widget buildFrame(MaterialTapTargetSize tapTargetSize, Key key) {
...@@ -797,7 +797,7 @@ void main() { ...@@ -797,7 +797,7 @@ void main() {
// Specifying minimumSize to mimic the original minimumSize for // Specifying minimumSize to mimic the original minimumSize for
// RaisedButton so that the corresponding button size matches // RaisedButton so that the corresponding button size matches
// the original version of this test. // the original version of this test.
minimumSize: MaterialStateProperty.all<Size>(const Size(88, 36)), minimumSize: const MaterialStatePropertyAll<Size>(Size(88, 36)),
), ),
key: key, key: key,
onPressed: () {}, onPressed: () {},
...@@ -861,8 +861,8 @@ void main() { ...@@ -861,8 +861,8 @@ void main() {
child: Center( child: Center(
child: ElevatedButton.icon( child: ElevatedButton.icon(
key: buttonKey, key: buttonKey,
style: ButtonStyle( style: const ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsets>(const EdgeInsets.fromLTRB(16, 5, 10, 12)), padding: MaterialStatePropertyAll<EdgeInsets>(EdgeInsets.fromLTRB(16, 5, 10, 12)),
), ),
onPressed: () {}, onPressed: () {},
icon: const Icon(Icons.add), icon: const Icon(Icons.add),
......
...@@ -30,4 +30,16 @@ void main() { ...@@ -30,4 +30,16 @@ void main() {
expect(value.resolve(<MaterialState>{MaterialState.disabled}), 123); expect(value.resolve(<MaterialState>{MaterialState.disabled}), 123);
expect(value.resolve(<MaterialState>{MaterialState.error}), 123); expect(value.resolve(<MaterialState>{MaterialState.error}), 123);
}); });
test('MaterialStatePropertyAll', () {
const MaterialStatePropertyAll<int> value = MaterialStatePropertyAll<int>(123);
expect(value.resolve(<MaterialState>{}), 123);
expect(value.resolve(<MaterialState>{MaterialState.hovered}), 123);
expect(value.resolve(<MaterialState>{MaterialState.focused}), 123);
expect(value.resolve(<MaterialState>{MaterialState.pressed}), 123);
expect(value.resolve(<MaterialState>{MaterialState.dragged}), 123);
expect(value.resolve(<MaterialState>{MaterialState.selected}), 123);
expect(value.resolve(<MaterialState>{MaterialState.disabled}), 123);
expect(value.resolve(<MaterialState>{MaterialState.error}), 123);
});
} }
...@@ -26,14 +26,14 @@ void main() { ...@@ -26,14 +26,14 @@ void main() {
testWidgets('Custom debugFillProperties', (WidgetTester tester) async { testWidgets('Custom debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
NavigationBarThemeData( const NavigationBarThemeData(
height: 200.0, height: 200.0,
backgroundColor: const Color(0x00000099), backgroundColor: Color(0x00000099),
elevation: 20.0, elevation: 20.0,
indicatorColor: const Color(0x00000098), indicatorColor: Color(0x00000098),
indicatorShape: const CircleBorder(), indicatorShape: CircleBorder(),
labelTextStyle: MaterialStateProperty.all(const TextStyle(fontSize: 7.0)), labelTextStyle: MaterialStatePropertyAll<TextStyle>(TextStyle(fontSize: 7.0)),
iconTheme: MaterialStateProperty.all(const IconThemeData(color: Color(0x00000097))), iconTheme: MaterialStatePropertyAll<IconThemeData>(IconThemeData(color: Color(0x00000097))),
labelBehavior: NavigationDestinationLabelBehavior.alwaysHide, labelBehavior: NavigationDestinationLabelBehavior.alwaysHide,
).debugFillProperties(builder); ).debugFillProperties(builder);
...@@ -47,10 +47,10 @@ void main() { ...@@ -47,10 +47,10 @@ void main() {
expect(description[2], 'elevation: 20.0'); expect(description[2], 'elevation: 20.0');
expect(description[3], 'indicatorColor: Color(0x00000098)'); expect(description[3], 'indicatorColor: Color(0x00000098)');
expect(description[4], 'indicatorShape: CircleBorder(BorderSide(Color(0xff000000), 0.0, BorderStyle.none))'); expect(description[4], 'indicatorShape: CircleBorder(BorderSide(Color(0xff000000), 0.0, BorderStyle.none))');
expect(description[5], 'labelTextStyle: MaterialStateProperty.all(TextStyle(inherit: true, size: 7.0))'); expect(description[5], 'labelTextStyle: MaterialStatePropertyAll(TextStyle(inherit: true, size: 7.0))');
// Ignore instance address for IconThemeData. // Ignore instance address for IconThemeData.
expect(description[6].contains('iconTheme: MaterialStateProperty.all(IconThemeData'), isTrue); expect(description[6].contains('iconTheme: MaterialStatePropertyAll(IconThemeData'), isTrue);
expect(description[6].contains('(color: Color(0x00000097))'), isTrue); expect(description[6].contains('(color: Color(0x00000097))'), isTrue);
expect(description[7], 'labelBehavior: NavigationDestinationLabelBehavior.alwaysHide'); expect(description[7], 'labelBehavior: NavigationDestinationLabelBehavior.alwaysHide');
......
...@@ -922,11 +922,11 @@ void main() { ...@@ -922,11 +922,11 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Center( child: Center(
child: OutlinedButton( child: OutlinedButton(
style: ButtonStyle( style: const ButtonStyle(
// Specifying minimumSize to mimic the original minimumSize for // Specifying minimumSize to mimic the original minimumSize for
// RaisedButton so that the corresponding button size matches // RaisedButton so that the corresponding button size matches
// the original version of this test. // the original version of this test.
minimumSize: MaterialStateProperty.all<Size>(const Size(88, 36)), minimumSize: MaterialStatePropertyAll<Size>(Size(88, 36)),
), ),
onPressed: () {}, onPressed: () {},
child: const Text('ABC'), child: const Text('ABC'),
...@@ -971,11 +971,11 @@ void main() { ...@@ -971,11 +971,11 @@ void main() {
data: const MediaQueryData(), data: const MediaQueryData(),
child: Center( child: Center(
child: OutlinedButton( child: OutlinedButton(
style: ButtonStyle( style: const ButtonStyle(
// Specifying minimumSize to mimic the original minimumSize for // Specifying minimumSize to mimic the original minimumSize for
// RaisedButton so that the corresponding button size matches // RaisedButton so that the corresponding button size matches
// the original version of this test. // the original version of this test.
minimumSize: MaterialStateProperty.all<Size>(const Size(88, 36)), minimumSize: MaterialStatePropertyAll<Size>(Size(88, 36)),
), ),
onPressed: () {}, onPressed: () {},
child: const Text('ABC'), child: const Text('ABC'),
...@@ -1000,11 +1000,11 @@ void main() { ...@@ -1000,11 +1000,11 @@ void main() {
data: const MediaQueryData(textScaleFactor: 1.3), data: const MediaQueryData(textScaleFactor: 1.3),
child: Center( child: Center(
child: OutlinedButton( child: OutlinedButton(
style: ButtonStyle( style: const ButtonStyle(
// Specifying minimumSize to mimic the original minimumSize for // Specifying minimumSize to mimic the original minimumSize for
// RaisedButton so that the corresponding button size matches // RaisedButton so that the corresponding button size matches
// the original version of this test. // the original version of this test.
minimumSize: MaterialStateProperty.all<Size>(const Size(88, 36)), minimumSize: MaterialStatePropertyAll<Size>(Size(88, 36)),
), ),
onPressed: () {}, onPressed: () {},
child: const Text('ABC'), child: const Text('ABC'),
......
...@@ -997,7 +997,7 @@ void main() { ...@@ -997,7 +997,7 @@ void main() {
value: active, value: active,
groupValue: true, groupValue: true,
onChanged: (_) { }, onChanged: (_) { },
fillColor: MaterialStateProperty.all(fillColor), fillColor: const MaterialStatePropertyAll<Color>(fillColor),
overlayColor: useOverlay ? MaterialStateProperty.resolveWith(getOverlayColor) : null, overlayColor: useOverlay ? MaterialStateProperty.resolveWith(getOverlayColor) : null,
hoverColor: hoverColor, hoverColor: hoverColor,
focusColor: focusColor, focusColor: focusColor,
......
...@@ -47,10 +47,10 @@ void main() { ...@@ -47,10 +47,10 @@ void main() {
testWidgets('RadioThemeData implements debugFillProperties', (WidgetTester tester) async { testWidgets('RadioThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
RadioThemeData( const RadioThemeData(
mouseCursor: MaterialStateProperty.all(SystemMouseCursors.click), mouseCursor: MaterialStatePropertyAll<MouseCursor>(SystemMouseCursors.click),
fillColor: MaterialStateProperty.all(const Color(0xfffffff0)), fillColor: MaterialStatePropertyAll<Color>(Color(0xfffffff0)),
overlayColor: MaterialStateProperty.all(const Color(0xfffffff1)), overlayColor: MaterialStatePropertyAll<Color>(Color(0xfffffff1)),
splashRadius: 1.0, splashRadius: 1.0,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
visualDensity: VisualDensity.standard, visualDensity: VisualDensity.standard,
...@@ -61,9 +61,9 @@ void main() { ...@@ -61,9 +61,9 @@ void main() {
.map((DiagnosticsNode node) => node.toString()) .map((DiagnosticsNode node) => node.toString())
.toList(); .toList();
expect(description[0], 'mouseCursor: MaterialStateProperty.all(SystemMouseCursor(click))'); expect(description[0], 'mouseCursor: MaterialStatePropertyAll(SystemMouseCursor(click))');
expect(description[1], 'fillColor: MaterialStateProperty.all(Color(0xfffffff0))'); expect(description[1], 'fillColor: MaterialStatePropertyAll(Color(0xfffffff0))');
expect(description[2], 'overlayColor: MaterialStateProperty.all(Color(0xfffffff1))'); expect(description[2], 'overlayColor: MaterialStatePropertyAll(Color(0xfffffff1))');
expect(description[3], 'splashRadius: 1.0'); expect(description[3], 'splashRadius: 1.0');
expect(description[4], 'materialTapTargetSize: MaterialTapTargetSize.shrinkWrap'); expect(description[4], 'materialTapTargetSize: MaterialTapTargetSize.shrinkWrap');
expect(description[5], equalsIgnoringHashCodes('visualDensity: VisualDensity#00000(h: 0.0, v: 0.0)')); expect(description[5], equalsIgnoringHashCodes('visualDensity: VisualDensity#00000(h: 0.0, v: 0.0)'));
...@@ -85,7 +85,7 @@ void main() { ...@@ -85,7 +85,7 @@ void main() {
return MaterialApp( return MaterialApp(
theme: ThemeData( theme: ThemeData(
radioTheme: RadioThemeData( radioTheme: RadioThemeData(
mouseCursor: MaterialStateProperty.all(mouseCursor), mouseCursor: const MaterialStatePropertyAll<MouseCursor>(mouseCursor),
fillColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) { fillColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
return selectedFillColor; return selectedFillColor;
...@@ -167,7 +167,7 @@ void main() { ...@@ -167,7 +167,7 @@ void main() {
return MaterialApp( return MaterialApp(
theme: ThemeData( theme: ThemeData(
radioTheme: RadioThemeData( radioTheme: RadioThemeData(
mouseCursor: MaterialStateProperty.all(themeMouseCursor), mouseCursor: const MaterialStatePropertyAll<MouseCursor>(themeMouseCursor),
fillColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) { fillColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
return themeSelectedFillColor; return themeSelectedFillColor;
...@@ -346,14 +346,14 @@ void main() { ...@@ -346,14 +346,14 @@ void main() {
Widget buildRadio({required bool active}) { Widget buildRadio({required bool active}) {
return MaterialApp( return MaterialApp(
theme: ThemeData( theme: ThemeData(
radioTheme: RadioThemeData( radioTheme: const RadioThemeData(
fillColor: MaterialStateProperty.all<Color>(globalThemeFillColor), fillColor: MaterialStatePropertyAll<Color>(globalThemeFillColor),
), ),
), ),
home: Scaffold( home: Scaffold(
body: RadioTheme( body: RadioTheme(
data: RadioThemeData( data: const RadioThemeData(
fillColor: MaterialStateProperty.all<Color>(localThemeFillColor), fillColor: MaterialStatePropertyAll<Color>(localThemeFillColor),
), ),
child: Radio<int>( child: Radio<int>(
value: active ? 1 : 0, value: active ? 1 : 0,
......
...@@ -1248,7 +1248,7 @@ void main() { ...@@ -1248,7 +1248,7 @@ void main() {
testWidgets('The mouse cursor is themeable', (WidgetTester tester) async { testWidgets('The mouse cursor is themeable', (WidgetTester tester) async {
await tester.pumpWidget(_buildApp( await tester.pumpWidget(_buildApp(
ThemeData().sliderTheme.copyWith( ThemeData().sliderTheme.copyWith(
mouseCursor: MaterialStateProperty.all(SystemMouseCursors.text), mouseCursor: const MaterialStatePropertyAll<MouseCursor>(SystemMouseCursors.text),
) )
)); ));
......
...@@ -1589,7 +1589,7 @@ void main() { ...@@ -1589,7 +1589,7 @@ void main() {
autofocus: focused, autofocus: focused,
value: active, value: active,
onChanged: (_) { }, onChanged: (_) { },
thumbColor: MaterialStateProperty.all(thumbColor), thumbColor: const MaterialStatePropertyAll<Color>(thumbColor),
overlayColor: useOverlay ? MaterialStateProperty.resolveWith(getOverlayColor) : null, overlayColor: useOverlay ? MaterialStateProperty.resolveWith(getOverlayColor) : null,
hoverColor: hoverColor, hoverColor: hoverColor,
focusColor: focusColor, focusColor: focusColor,
......
...@@ -47,12 +47,12 @@ void main() { ...@@ -47,12 +47,12 @@ void main() {
testWidgets('SwitchThemeData implements debugFillProperties', (WidgetTester tester) async { testWidgets('SwitchThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
SwitchThemeData( const SwitchThemeData(
thumbColor: MaterialStateProperty.all(const Color(0xfffffff0)), thumbColor: MaterialStatePropertyAll<Color>(Color(0xfffffff0)),
trackColor: MaterialStateProperty.all(const Color(0xfffffff1)), trackColor: MaterialStatePropertyAll<Color>(Color(0xfffffff1)),
mouseCursor: MaterialStateProperty.all(SystemMouseCursors.click), mouseCursor: MaterialStatePropertyAll<MouseCursor>(SystemMouseCursors.click),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
overlayColor: MaterialStateProperty.all(const Color(0xfffffff2)), overlayColor: MaterialStatePropertyAll<Color>(Color(0xfffffff2)),
splashRadius: 1.0, splashRadius: 1.0,
).debugFillProperties(builder); ).debugFillProperties(builder);
...@@ -61,11 +61,11 @@ void main() { ...@@ -61,11 +61,11 @@ void main() {
.map((DiagnosticsNode node) => node.toString()) .map((DiagnosticsNode node) => node.toString())
.toList(); .toList();
expect(description[0], 'thumbColor: MaterialStateProperty.all(Color(0xfffffff0))'); expect(description[0], 'thumbColor: MaterialStatePropertyAll(Color(0xfffffff0))');
expect(description[1], 'trackColor: MaterialStateProperty.all(Color(0xfffffff1))'); expect(description[1], 'trackColor: MaterialStatePropertyAll(Color(0xfffffff1))');
expect(description[2], 'materialTapTargetSize: MaterialTapTargetSize.shrinkWrap'); expect(description[2], 'materialTapTargetSize: MaterialTapTargetSize.shrinkWrap');
expect(description[3], 'mouseCursor: MaterialStateProperty.all(SystemMouseCursor(click))'); expect(description[3], 'mouseCursor: MaterialStatePropertyAll(SystemMouseCursor(click))');
expect(description[4], 'overlayColor: MaterialStateProperty.all(Color(0xfffffff2))'); expect(description[4], 'overlayColor: MaterialStatePropertyAll(Color(0xfffffff2))');
expect(description[5], 'splashRadius: 1.0'); expect(description[5], 'splashRadius: 1.0');
}); });
...@@ -98,7 +98,7 @@ void main() { ...@@ -98,7 +98,7 @@ void main() {
} }
return defaultTrackColor; return defaultTrackColor;
}), }),
mouseCursor: MaterialStateProperty.all(mouseCursor), mouseCursor: const MaterialStatePropertyAll<MouseCursor>(mouseCursor),
materialTapTargetSize: materialTapTargetSize, materialTapTargetSize: materialTapTargetSize,
overlayColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) { overlayColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
...@@ -203,7 +203,7 @@ void main() { ...@@ -203,7 +203,7 @@ void main() {
} }
return themeDefaultTrackColor; return themeDefaultTrackColor;
}), }),
mouseCursor: MaterialStateProperty.all(themeMouseCursor), mouseCursor: const MaterialStatePropertyAll<MouseCursor>(themeMouseCursor),
materialTapTargetSize: themeMaterialTapTargetSize, materialTapTargetSize: themeMaterialTapTargetSize,
overlayColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) { overlayColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.focused)) { if (states.contains(MaterialState.focused)) {
...@@ -429,16 +429,16 @@ void main() { ...@@ -429,16 +429,16 @@ void main() {
Widget buildSwitch({bool selected = false, bool autofocus = false}) { Widget buildSwitch({bool selected = false, bool autofocus = false}) {
return MaterialApp( return MaterialApp(
theme: ThemeData( theme: ThemeData(
switchTheme: SwitchThemeData( switchTheme: const SwitchThemeData(
thumbColor: MaterialStateProperty.all<Color>(globalThemeThumbColor), thumbColor: MaterialStatePropertyAll<Color>(globalThemeThumbColor),
trackColor: MaterialStateProperty.all<Color>(globalThemeTrackColor), trackColor: MaterialStatePropertyAll<Color>(globalThemeTrackColor),
), ),
), ),
home: Scaffold( home: Scaffold(
body: SwitchTheme( body: SwitchTheme(
data: SwitchThemeData( data: const SwitchThemeData(
thumbColor: MaterialStateProperty.all<Color>(localThemeThumbColor), thumbColor: MaterialStatePropertyAll<Color>(localThemeThumbColor),
trackColor: MaterialStateProperty.all<Color>(localThemeTrackColor), trackColor: MaterialStatePropertyAll<Color>(localThemeTrackColor),
), ),
child: Switch( child: Switch(
value: selected, value: selected,
......
...@@ -492,11 +492,11 @@ void main() { ...@@ -492,11 +492,11 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Center( child: Center(
child: TextButton( child: TextButton(
style: ButtonStyle( style: const ButtonStyle(
// Specifying minimumSize to mimic the original minimumSize for // Specifying minimumSize to mimic the original minimumSize for
// RaisedButton so that the semantics tree's rect and transform // RaisedButton so that the semantics tree's rect and transform
// match the original version of this test. // match the original version of this test.
minimumSize: MaterialStateProperty.all<Size>(const Size(88, 36)), minimumSize: MaterialStatePropertyAll<Size>(Size(88, 36)),
), ),
onPressed: () { }, onPressed: () { },
child: const Text('ABC'), child: const Text('ABC'),
......
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