Migrate more files to WidgetStateProperty (#174268)

Another batch of files migrated to use WidgetStateProperty

Follow up of https://github.com/flutter/flutter/pull/174176

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
Valentin Vignal 2025-08-23 01:23:53 +08:00 committed by GitHub
parent bdea526c66
commit f0f208deae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
35 changed files with 194 additions and 215 deletions

View File

@ -6,7 +6,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'ink_well.dart';
import 'material_state.dart';
import 'tabs.dart';
import 'theme.dart';
@ -92,9 +91,9 @@ class TabBarTheme extends InheritedTheme with Diagnosticable {
final TextStyle? _labelStyle;
final Color? _unselectedLabelColor;
final TextStyle? _unselectedLabelStyle;
final MaterialStateProperty<Color?>? _overlayColor;
final WidgetStateProperty<Color?>? _overlayColor;
final InteractiveInkFeatureFactory? _splashFactory;
final MaterialStateProperty<MouseCursor?>? _mouseCursor;
final WidgetStateProperty<MouseCursor?>? _mouseCursor;
final TabAlignment? _tabAlignment;
final TextScaler? _textScaler;
final TabIndicatorAnimation? _indicatorAnimation;
@ -165,7 +164,7 @@ class TabBarTheme extends InheritedTheme with Diagnosticable {
///
/// This property is obsolete and will be deprecated in a future release:
/// please use the [TabBarThemeData.overlayColor] property in [data] instead.
MaterialStateProperty<Color?>? get overlayColor =>
WidgetStateProperty<Color?>? get overlayColor =>
_data != null ? _data.overlayColor : _overlayColor;
/// Overrides the default value for [TabBar.splashFactory].
@ -179,7 +178,7 @@ class TabBarTheme extends InheritedTheme with Diagnosticable {
///
/// This property is obsolete and will be deprecated in a future release:
/// please use the [TabBarThemeData.mouseCursor] property in [data] instead.
MaterialStateProperty<MouseCursor?>? get mouseCursor =>
WidgetStateProperty<MouseCursor?>? get mouseCursor =>
_data != null ? _data.mouseCursor : _mouseCursor;
/// Overrides the default value for [TabBar.tabAlignment].
@ -239,9 +238,9 @@ class TabBarTheme extends InheritedTheme with Diagnosticable {
TextStyle? labelStyle,
Color? unselectedLabelColor,
TextStyle? unselectedLabelStyle,
MaterialStateProperty<Color?>? overlayColor,
WidgetStateProperty<Color?>? overlayColor,
InteractiveInkFeatureFactory? splashFactory,
MaterialStateProperty<MouseCursor?>? mouseCursor,
WidgetStateProperty<MouseCursor?>? mouseCursor,
TabAlignment? tabAlignment,
TextScaler? textScaler,
TabIndicatorAnimation? indicatorAnimation,
@ -293,12 +292,7 @@ class TabBarTheme extends InheritedTheme with Diagnosticable {
labelStyle: TextStyle.lerp(a.labelStyle, b.labelStyle, t),
unselectedLabelColor: Color.lerp(a.unselectedLabelColor, b.unselectedLabelColor, t),
unselectedLabelStyle: TextStyle.lerp(a.unselectedLabelStyle, b.unselectedLabelStyle, t),
overlayColor: MaterialStateProperty.lerp<Color?>(
a.overlayColor,
b.overlayColor,
t,
Color.lerp,
),
overlayColor: WidgetStateProperty.lerp<Color?>(a.overlayColor, b.overlayColor, t, Color.lerp),
splashFactory: t < 0.5 ? a.splashFactory : b.splashFactory,
mouseCursor: t < 0.5 ? a.mouseCursor : b.mouseCursor,
tabAlignment: t < 0.5 ? a.tabAlignment : b.tabAlignment,
@ -398,7 +392,7 @@ class TabBarThemeData with Diagnosticable {
final TextStyle? unselectedLabelStyle;
/// Overrides the default value for [TabBar.overlayColor].
final MaterialStateProperty<Color?>? overlayColor;
final WidgetStateProperty<Color?>? overlayColor;
/// Overrides the default value for [TabBar.splashFactory].
final InteractiveInkFeatureFactory? splashFactory;
@ -406,7 +400,7 @@ class TabBarThemeData with Diagnosticable {
/// {@macro flutter.material.tabs.mouseCursor}
///
/// If specified, overrides the default value of [TabBar.mouseCursor].
final MaterialStateProperty<MouseCursor?>? mouseCursor;
final WidgetStateProperty<MouseCursor?>? mouseCursor;
/// Overrides the default value for [TabBar.tabAlignment].
final TabAlignment? tabAlignment;
@ -433,9 +427,9 @@ class TabBarThemeData with Diagnosticable {
TextStyle? labelStyle,
Color? unselectedLabelColor,
TextStyle? unselectedLabelStyle,
MaterialStateProperty<Color?>? overlayColor,
WidgetStateProperty<Color?>? overlayColor,
InteractiveInkFeatureFactory? splashFactory,
MaterialStateProperty<MouseCursor?>? mouseCursor,
WidgetStateProperty<MouseCursor?>? mouseCursor,
TabAlignment? tabAlignment,
TextScaler? textScaler,
TabIndicatorAnimation? indicatorAnimation,
@ -480,12 +474,7 @@ class TabBarThemeData with Diagnosticable {
labelStyle: TextStyle.lerp(a.labelStyle, b.labelStyle, t),
unselectedLabelColor: Color.lerp(a.unselectedLabelColor, b.unselectedLabelColor, t),
unselectedLabelStyle: TextStyle.lerp(a.unselectedLabelStyle, b.unselectedLabelStyle, t),
overlayColor: MaterialStateProperty.lerp<Color?>(
a.overlayColor,
b.overlayColor,
t,
Color.lerp,
),
overlayColor: WidgetStateProperty.lerp<Color?>(a.overlayColor, b.overlayColor, t, Color.lerp),
splashFactory: t < 0.5 ? a.splashFactory : b.splashFactory,
mouseCursor: t < 0.5 ? a.mouseCursor : b.mouseCursor,
tabAlignment: t < 0.5 ? a.tabAlignment : b.tabAlignment,
@ -574,7 +563,7 @@ class TabBarThemeData with Diagnosticable {
),
);
properties.add(
DiagnosticsProperty<MaterialStateProperty<Color?>?>(
DiagnosticsProperty<WidgetStateProperty<Color?>?>(
'overlayColor',
overlayColor,
defaultValue: null,
@ -588,7 +577,7 @@ class TabBarThemeData with Diagnosticable {
),
);
properties.add(
DiagnosticsProperty<MaterialStateProperty<MouseCursor?>?>(
DiagnosticsProperty<WidgetStateProperty<MouseCursor?>?>(
'mouseCursor',
mouseCursor,
defaultValue: null,

View File

@ -1226,7 +1226,7 @@ class TabBar extends StatefulWidget implements PreferredSizeWidget {
/// * pressed - ThemeData.colorScheme.primary(0.1)
/// * hovered - ThemeData.colorScheme.onSurface(0.08)
/// * focused - ThemeData.colorScheme.onSurface(0.1)
final MaterialStateProperty<Color?>? overlayColor;
final WidgetStateProperty<Color?>? overlayColor;
/// {@macro flutter.widgets.scrollable.dragStartBehavior}
final DragStartBehavior dragStartBehavior;
@ -1930,15 +1930,16 @@ class _TabBarState extends State<TabBar> {
};
final MouseCursor effectiveMouseCursor =
MaterialStateProperty.resolveAs<MouseCursor?>(widget.mouseCursor, selectedState) ??
WidgetStateProperty.resolveAs<MouseCursor?>(widget.mouseCursor, selectedState) ??
tabBarTheme.mouseCursor?.resolve(selectedState) ??
MaterialStateMouseCursor.clickable.resolve(selectedState);
final MaterialStateProperty<Color?> defaultOverlay =
MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
final Set<MaterialState> effectiveStates = selectedState..addAll(states);
return _defaults.overlayColor?.resolve(effectiveStates);
});
final WidgetStateProperty<Color?> defaultOverlay = WidgetStateProperty.resolveWith<Color?>((
Set<MaterialState> states,
) {
final Set<MaterialState> effectiveStates = selectedState..addAll(states);
return _defaults.overlayColor?.resolve(effectiveStates);
});
wrappedTabs[index] = InkWell(
mouseCursor: effectiveMouseCursor,
onTap: () {

View File

@ -229,21 +229,18 @@ class TextButton extends ButtonStyleButton {
ButtonLayerBuilder? backgroundBuilder,
ButtonLayerBuilder? foregroundBuilder,
}) {
final MaterialStateProperty<Color?>? backgroundColorProp = switch ((
final WidgetStateProperty<Color?>? backgroundColorProp = switch ((
backgroundColor,
disabledBackgroundColor,
)) {
(_?, null) => MaterialStatePropertyAll<Color?>(backgroundColor),
(_, _) => ButtonStyleButton.defaultColor(backgroundColor, disabledBackgroundColor),
};
final MaterialStateProperty<Color?>? iconColorProp = switch ((iconColor, disabledIconColor)) {
final WidgetStateProperty<Color?>? iconColorProp = switch ((iconColor, disabledIconColor)) {
(_?, null) => MaterialStatePropertyAll<Color?>(iconColor),
(_, _) => ButtonStyleButton.defaultColor(iconColor, disabledIconColor),
};
final MaterialStateProperty<Color?>? overlayColorProp = switch ((
foregroundColor,
overlayColor,
)) {
final WidgetStateProperty<Color?>? overlayColorProp = switch ((foregroundColor, overlayColor)) {
(null, null) => null,
(_, Color(a: 0.0)) => WidgetStatePropertyAll<Color?>(overlayColor),
(_, final Color color) ||

View File

@ -1461,7 +1461,7 @@ class _TextFieldState extends State<TextField>
MaterialStatesController? _internalStatesController;
void _handleStatesControllerChange() {
// Force a rebuild to resolve MaterialStateProperty properties.
// Force a rebuild to resolve WidgetStateProperty properties.
setState(() {});
}
@ -1506,11 +1506,11 @@ class _TextFieldState extends State<TextField>
TextStyle _getInputStyleForState(TextStyle style) {
final ThemeData theme = Theme.of(context);
final TextStyle stateStyle = MaterialStateProperty.resolveAs(
final TextStyle stateStyle = WidgetStateProperty.resolveAs(
theme.useMaterial3 ? _m3StateInputStyle(context)! : _m2StateInputStyle(context)!,
_statesController.value,
);
final TextStyle providedStyle = MaterialStateProperty.resolveAs(style, _statesController.value);
final TextStyle providedStyle = WidgetStateProperty.resolveAs(style, _statesController.value);
return providedStyle.merge(stateStyle);
}
@ -1528,7 +1528,7 @@ class _TextFieldState extends State<TextField>
final ThemeData theme = Theme.of(context);
final DefaultSelectionStyle selectionStyle = DefaultSelectionStyle.of(context);
final TextStyle? providedStyle = MaterialStateProperty.resolveAs(
final TextStyle? providedStyle = WidgetStateProperty.resolveAs(
widget.style,
_statesController.value,
);
@ -1767,7 +1767,7 @@ class _TextFieldState extends State<TextField>
child: child,
);
}
final MouseCursor effectiveMouseCursor = MaterialStateProperty.resolveAs<MouseCursor>(
final MouseCursor effectiveMouseCursor = WidgetStateProperty.resolveAs<MouseCursor>(
widget.mouseCursor ?? MaterialStateMouseCursor.textable,
_statesController.value,
);

View File

@ -360,12 +360,12 @@ class _HourMinuteControl extends StatelessWidget {
final ShapeBorder shape = timePickerTheme.hourMinuteShape ?? defaultTheme.hourMinuteShape;
final Set<MaterialState> states = <MaterialState>{if (isSelected) MaterialState.selected};
final Color effectiveTextColor = MaterialStateProperty.resolveAs<Color>(
final Color effectiveTextColor = WidgetStateProperty.resolveAs<Color>(
_TimePickerModel.themeOf(context).hourMinuteTextColor ??
_TimePickerModel.defaultThemeOf(context).hourMinuteTextColor,
states,
);
final TextStyle effectiveStyle = MaterialStateProperty.resolveAs<TextStyle>(
final TextStyle effectiveStyle = WidgetStateProperty.resolveAs<TextStyle>(
timePickerTheme.hourMinuteTextStyle ?? defaultTheme.hourMinuteTextStyle,
states,
).copyWith(color: effectiveTextColor);
@ -383,7 +383,7 @@ class _HourMinuteControl extends StatelessWidget {
return SizedBox(
height: height,
child: Material(
color: MaterialStateProperty.resolveAs(backgroundColor, states),
color: WidgetStateProperty.resolveAs(backgroundColor, states),
clipBehavior: Clip.antiAlias,
shape: shape,
child: InkWell(
@ -497,14 +497,14 @@ class _TimeSelectorSeparator extends StatelessWidget {
: _TimePickerDefaultsM2(context);
final Set<MaterialState> states = <MaterialState>{};
final Color effectiveTextColor = MaterialStateProperty.resolveAs<Color>(
final Color effectiveTextColor = WidgetStateProperty.resolveAs<Color>(
timePickerTheme.timeSelectorSeparatorColor?.resolve(states) ??
timePickerTheme.hourMinuteTextColor ??
defaultTheme.timeSelectorSeparatorColor?.resolve(states) ??
defaultTheme.hourMinuteTextColor,
states,
);
final TextStyle effectiveStyle = MaterialStateProperty.resolveAs<TextStyle>(
final TextStyle effectiveStyle = WidgetStateProperty.resolveAs<TextStyle>(
timePickerTheme.timeSelectorSeparatorTextStyle?.resolve(states) ??
timePickerTheme.hourMinuteTextStyle ??
defaultTheme.timeSelectorSeparatorTextStyle?.resolve(states) ??
@ -791,15 +791,15 @@ class _AmPmButton extends StatelessWidget {
final Set<MaterialState> states = <MaterialState>{if (selected) MaterialState.selected};
final TimePickerThemeData timePickerTheme = _TimePickerModel.themeOf(context);
final _TimePickerDefaults defaultTheme = _TimePickerModel.defaultThemeOf(context);
final Color resolvedBackgroundColor = MaterialStateProperty.resolveAs<Color>(
final Color resolvedBackgroundColor = WidgetStateProperty.resolveAs<Color>(
timePickerTheme.dayPeriodColor ?? defaultTheme.dayPeriodColor,
states,
);
final Color resolvedTextColor = MaterialStateProperty.resolveAs<Color>(
final Color resolvedTextColor = WidgetStateProperty.resolveAs<Color>(
timePickerTheme.dayPeriodTextColor ?? defaultTheme.dayPeriodTextColor,
states,
);
final TextStyle? resolvedTextStyle = MaterialStateProperty.resolveAs<TextStyle?>(
final TextStyle? resolvedTextStyle = WidgetStateProperty.resolveAs<TextStyle?>(
timePickerTheme.dayPeriodTextStyle ?? defaultTheme.dayPeriodTextStyle,
states,
)?.copyWith(color: resolvedTextColor);
@ -1621,11 +1621,11 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
timePickerTheme.dialBackgroundColor ?? defaultTheme.dialBackgroundColor;
final Color dialHandColor = timePickerTheme.dialHandColor ?? defaultTheme.dialHandColor;
final TextStyle labelStyle = timePickerTheme.dialTextStyle ?? defaultTheme.dialTextStyle;
final Color dialTextUnselectedColor = MaterialStateProperty.resolveAs<Color>(
final Color dialTextUnselectedColor = WidgetStateProperty.resolveAs<Color>(
timePickerTheme.dialTextColor ?? defaultTheme.dialTextColor,
<MaterialState>{},
);
final Color dialTextSelectedColor = MaterialStateProperty.resolveAs<Color>(
final Color dialTextSelectedColor = WidgetStateProperty.resolveAs<Color>(
timePickerTheme.dialTextColor ?? defaultTheme.dialTextColor,
<MaterialState>{MaterialState.selected},
);
@ -2234,7 +2234,7 @@ class _HourMinuteTextFieldState extends State<_HourMinuteTextField> with Restora
defaultTheme.hourMinuteColor;
final Color fillColor;
if (theme.useMaterial3) {
fillColor = MaterialStateProperty.resolveAs<Color>(startingFillColor, <MaterialState>{
fillColor = WidgetStateProperty.resolveAs<Color>(startingFillColor, <MaterialState>{
if (focusNode.hasFocus) MaterialState.focused,
if (focusNode.hasFocus) MaterialState.selected,
});
@ -2248,11 +2248,11 @@ class _HourMinuteTextFieldState extends State<_HourMinuteTextField> with Restora
if (focusNode.hasFocus) MaterialState.focused,
if (focusNode.hasFocus) MaterialState.selected,
};
final Color effectiveTextColor = MaterialStateProperty.resolveAs<Color>(
final Color effectiveTextColor = WidgetStateProperty.resolveAs<Color>(
timePickerTheme.hourMinuteTextColor ?? defaultTheme.hourMinuteTextColor,
states,
);
final TextStyle effectiveStyle = MaterialStateProperty.resolveAs<TextStyle>(
final TextStyle effectiveStyle = WidgetStateProperty.resolveAs<TextStyle>(
widget.style,
states,
).copyWith(color: effectiveTextColor);

View File

@ -303,7 +303,7 @@ class TimePickerThemeData with Diagnosticable {
///
/// If this is null and [ThemeData.useMaterial3] is false, then defaults to the value of
/// [hourMinuteTextColor].
final MaterialStateProperty<Color?>? timeSelectorSeparatorColor;
final WidgetStateProperty<Color?>? timeSelectorSeparatorColor;
/// Used to configure the text style for the time selector separator between the hour
/// and minute controls.
@ -313,7 +313,7 @@ class TimePickerThemeData with Diagnosticable {
///
/// If this is null and [ThemeData.useMaterial3] is false, then defaults to the value of
/// [hourMinuteTextStyle].
final MaterialStateProperty<TextStyle?>? timeSelectorSeparatorTextStyle;
final WidgetStateProperty<TextStyle?>? timeSelectorSeparatorTextStyle;
/// Creates a copy of this object with the given fields replaced with the
/// new values.
@ -341,8 +341,8 @@ class TimePickerThemeData with Diagnosticable {
InputDecorationTheme? inputDecorationTheme,
EdgeInsetsGeometry? padding,
ShapeBorder? shape,
MaterialStateProperty<Color?>? timeSelectorSeparatorColor,
MaterialStateProperty<TextStyle?>? timeSelectorSeparatorTextStyle,
WidgetStateProperty<Color?>? timeSelectorSeparatorColor,
WidgetStateProperty<TextStyle?>? timeSelectorSeparatorTextStyle,
}) {
return TimePickerThemeData(
backgroundColor: backgroundColor ?? this.backgroundColor,
@ -414,13 +414,13 @@ class TimePickerThemeData with Diagnosticable {
inputDecorationTheme: t < 0.5 ? a?.inputDecorationTheme : b?.inputDecorationTheme,
padding: EdgeInsetsGeometry.lerp(a?.padding, b?.padding, t),
shape: ShapeBorder.lerp(a?.shape, b?.shape, t),
timeSelectorSeparatorColor: MaterialStateProperty.lerp<Color?>(
timeSelectorSeparatorColor: WidgetStateProperty.lerp<Color?>(
a?.timeSelectorSeparatorColor,
b?.timeSelectorSeparatorColor,
t,
Color.lerp,
),
timeSelectorSeparatorTextStyle: MaterialStateProperty.lerp<TextStyle?>(
timeSelectorSeparatorTextStyle: WidgetStateProperty.lerp<TextStyle?>(
a?.timeSelectorSeparatorTextStyle,
b?.timeSelectorSeparatorTextStyle,
t,
@ -554,14 +554,14 @@ class TimePickerThemeData with Diagnosticable {
properties.add(DiagnosticsProperty<EdgeInsetsGeometry>('padding', padding, defaultValue: null));
properties.add(DiagnosticsProperty<ShapeBorder>('shape', shape, defaultValue: null));
properties.add(
DiagnosticsProperty<MaterialStateProperty<Color?>>(
DiagnosticsProperty<WidgetStateProperty<Color?>>(
'timeSelectorSeparatorColor',
timeSelectorSeparatorColor,
defaultValue: null,
),
);
properties.add(
DiagnosticsProperty<MaterialStateProperty<TextStyle?>>(
DiagnosticsProperty<WidgetStateProperty<TextStyle?>>(
'timeSelectorSeparatorTextStyle',
timeSelectorSeparatorTextStyle,
defaultValue: null,

View File

@ -903,22 +903,22 @@ class ToggleButtons extends StatelessWidget {
}
@immutable
class _ResolveFillColor extends MaterialStateProperty<Color?> with Diagnosticable {
class _ResolveFillColor extends WidgetStateProperty<Color?> with Diagnosticable {
_ResolveFillColor(this.primary);
final Color? primary;
@override
Color? resolve(Set<MaterialState> states) {
if (primary is MaterialStateProperty<Color>) {
return MaterialStateProperty.resolveAs<Color?>(primary, states);
if (primary is WidgetStateProperty<Color>) {
return WidgetStateProperty.resolveAs<Color?>(primary, states);
}
return states.contains(MaterialState.selected) ? primary : null;
}
}
@immutable
class _DefaultFillColor extends MaterialStateProperty<Color> with Diagnosticable {
class _DefaultFillColor extends WidgetStateProperty<Color> with Diagnosticable {
_DefaultFillColor(this.colorScheme);
final ColorScheme colorScheme;
@ -933,7 +933,7 @@ class _DefaultFillColor extends MaterialStateProperty<Color> with Diagnosticable
}
@immutable
class _ToggleButtonDefaultOverlay extends MaterialStateProperty<Color?> {
class _ToggleButtonDefaultOverlay extends WidgetStateProperty<Color?> {
_ToggleButtonDefaultOverlay({
required this.selected,
required this.unselected,

View File

@ -247,7 +247,7 @@ void main() {
testWidgets('ActionChip.color resolves material states', (WidgetTester tester) async {
const Color disabledColor = Color(0xff00ff00);
const Color backgroundColor = Color(0xff0000ff);
final MaterialStateProperty<Color?> color = MaterialStateProperty.resolveWith((
final WidgetStateProperty<Color?> color = WidgetStateProperty.resolveWith((
Set<MaterialState> states,
) {
if (states.contains(MaterialState.disabled)) {

View File

@ -139,9 +139,7 @@ void main() {
type: BottomNavigationBarType.fixed,
selectedLabelStyle: selectedTextStyle,
unselectedLabelStyle: unselectedTextStyle,
mouseCursor: MaterialStateProperty.resolveWith<MouseCursor?>((
Set<MaterialState> states,
) {
mouseCursor: WidgetStateProperty.resolveWith<MouseCursor?>((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
return SystemMouseCursors.grab;
}

View File

@ -1254,7 +1254,7 @@ void main() {
semantics.dispose();
});
testWidgets('Drag handle color can take MaterialStateProperty', (WidgetTester tester) async {
testWidgets('Drag handle color can take WidgetStateProperty', (WidgetTester tester) async {
const Color defaultColor = Colors.blue;
const Color hoveringColor = Colors.green;

View File

@ -110,42 +110,38 @@ void main() {
});
testWidgets('ButtonStyle copyWith, merge', (WidgetTester tester) async {
const MaterialStateProperty<TextStyle> textStyle = MaterialStatePropertyAll<TextStyle>(
const WidgetStateProperty<TextStyle> textStyle = MaterialStatePropertyAll<TextStyle>(
TextStyle(fontSize: 10),
);
const MaterialStateProperty<Color> backgroundColor = MaterialStatePropertyAll<Color>(
const WidgetStateProperty<Color> backgroundColor = MaterialStatePropertyAll<Color>(
Color(0xfffffff1),
);
const MaterialStateProperty<Color> foregroundColor = MaterialStatePropertyAll<Color>(
const WidgetStateProperty<Color> foregroundColor = MaterialStatePropertyAll<Color>(
Color(0xfffffff2),
);
const MaterialStateProperty<Color> overlayColor = MaterialStatePropertyAll<Color>(
const WidgetStateProperty<Color> overlayColor = MaterialStatePropertyAll<Color>(
Color(0xfffffff3),
);
const MaterialStateProperty<Color> shadowColor = MaterialStatePropertyAll<Color>(
const WidgetStateProperty<Color> shadowColor = MaterialStatePropertyAll<Color>(
Color(0xfffffff4),
);
const MaterialStateProperty<Color> surfaceTintColor = MaterialStatePropertyAll<Color>(
const WidgetStateProperty<Color> surfaceTintColor = MaterialStatePropertyAll<Color>(
Color(0xfffffff5),
);
const MaterialStateProperty<double> elevation = MaterialStatePropertyAll<double>(1);
const MaterialStateProperty<EdgeInsets> padding = MaterialStatePropertyAll<EdgeInsets>(
const WidgetStateProperty<double> elevation = MaterialStatePropertyAll<double>(1);
const WidgetStateProperty<EdgeInsets> padding = MaterialStatePropertyAll<EdgeInsets>(
EdgeInsets.all(1),
);
const MaterialStateProperty<Size> minimumSize = MaterialStatePropertyAll<Size>(Size(1, 2));
const MaterialStateProperty<Size> fixedSize = MaterialStatePropertyAll<Size>(Size(3, 4));
const MaterialStateProperty<Size> maximumSize = MaterialStatePropertyAll<Size>(Size(5, 6));
const MaterialStateProperty<Color> iconColor = MaterialStatePropertyAll<Color>(
Color(0xfffffff6),
);
const MaterialStateProperty<double> iconSize = MaterialStatePropertyAll<double>(48.0);
const MaterialStateProperty<BorderSide> side = MaterialStatePropertyAll<BorderSide>(
BorderSide(),
);
const MaterialStateProperty<OutlinedBorder> shape = MaterialStatePropertyAll<OutlinedBorder>(
const WidgetStateProperty<Size> minimumSize = MaterialStatePropertyAll<Size>(Size(1, 2));
const WidgetStateProperty<Size> fixedSize = MaterialStatePropertyAll<Size>(Size(3, 4));
const WidgetStateProperty<Size> maximumSize = MaterialStatePropertyAll<Size>(Size(5, 6));
const WidgetStateProperty<Color> iconColor = MaterialStatePropertyAll<Color>(Color(0xfffffff6));
const WidgetStateProperty<double> iconSize = MaterialStatePropertyAll<double>(48.0);
const WidgetStateProperty<BorderSide> side = MaterialStatePropertyAll<BorderSide>(BorderSide());
const WidgetStateProperty<OutlinedBorder> shape = MaterialStatePropertyAll<OutlinedBorder>(
StadiumBorder(),
);
const MaterialStateProperty<MouseCursor> mouseCursor = MaterialStatePropertyAll<MouseCursor>(
const WidgetStateProperty<MouseCursor> mouseCursor = MaterialStatePropertyAll<MouseCursor>(
SystemMouseCursors.forbidden,
);
const VisualDensity visualDensity = VisualDensity.compact;

View File

@ -122,7 +122,7 @@ void main() {
child: Theme(
data: ThemeData(
checkboxTheme: CheckboxThemeData(
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
fillColor: WidgetStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
return states.contains(MaterialState.selected) ? themeColor : null;
}),
),
@ -356,7 +356,7 @@ void main() {
return MaterialApp(
theme: ThemeData(
checkboxTheme: CheckboxThemeData(
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
fillColor: WidgetStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
return states.contains(MaterialState.selected) ? fillColor : null;
}),
),
@ -647,7 +647,7 @@ void main() {
return activeEnabledFillColor;
}
final MaterialStateProperty<Color> fillColor = MaterialStateColor.resolveWith(getFillColor);
final WidgetStateProperty<Color> fillColor = MaterialStateColor.resolveWith(getFillColor);
Widget buildFrame({required bool enabled}) {
return wrap(
@ -683,7 +683,7 @@ void main() {
return Colors.transparent;
}
final MaterialStateProperty<Color> fillColor = MaterialStateColor.resolveWith(getFillColor);
final WidgetStateProperty<Color> fillColor = MaterialStateColor.resolveWith(getFillColor);
Widget buildFrame() {
return wrap(
@ -802,7 +802,7 @@ void main() {
value: active,
onChanged: (_) {},
fillColor: const MaterialStatePropertyAll<Color>(fillColor),
overlayColor: useOverlay ? MaterialStateProperty.resolveWith(getOverlayColor) : null,
overlayColor: useOverlay ? WidgetStateProperty.resolveWith(getOverlayColor) : null,
hoverColor: hoverColor,
splashRadius: splashRadius,
),
@ -924,7 +924,7 @@ void main() {
value: active,
onChanged: (_) {},
fillColor: const MaterialStatePropertyAll<Color>(fillColor),
overlayColor: useOverlay ? MaterialStateProperty.resolveWith(getOverlayColor) : null,
overlayColor: useOverlay ? WidgetStateProperty.resolveWith(getOverlayColor) : null,
hoverColor: hoverColor,
splashRadius: splashRadius,
),

View File

@ -1343,7 +1343,7 @@ void main() {
return activeEnabledFillColor;
}
final MaterialStateProperty<Color> fillColor = MaterialStateColor.resolveWith(getFillColor);
final WidgetStateProperty<Color> fillColor = MaterialStateColor.resolveWith(getFillColor);
Widget buildFrame({required bool enabled}) {
return Material(
@ -1395,7 +1395,7 @@ void main() {
return Colors.transparent;
}
final MaterialStateProperty<Color> fillColor = MaterialStateColor.resolveWith(getFillColor);
final WidgetStateProperty<Color> fillColor = MaterialStateColor.resolveWith(getFillColor);
Widget buildFrame() {
return Material(
@ -1680,7 +1680,7 @@ void main() {
value: active,
onChanged: (_) {},
fillColor: const MaterialStatePropertyAll<Color>(fillColor),
overlayColor: useOverlay ? MaterialStateProperty.resolveWith(getOverlayColor) : null,
overlayColor: useOverlay ? WidgetStateProperty.resolveWith(getOverlayColor) : null,
hoverColor: hoverColor,
focusColor: focusColor,
splashRadius: splashRadius,
@ -1795,7 +1795,7 @@ void main() {
value = v;
});
},
overlayColor: MaterialStateProperty.resolveWith(getOverlayColor),
overlayColor: WidgetStateProperty.resolveWith(getOverlayColor),
splashRadius: splashRadius,
);
},
@ -2401,7 +2401,7 @@ void main() {
home: Material(
child: Center(
child: Checkbox(
fillColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
fillColor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
return activeBackgroundColor;
}
@ -2444,7 +2444,7 @@ void main() {
home: Material(
child: Center(
child: Checkbox(
fillColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
fillColor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
return activeBackgroundColor;
}

View File

@ -101,19 +101,19 @@ void main() {
theme: ThemeData(
checkboxTheme: CheckboxThemeData(
mouseCursor: const MaterialStatePropertyAll<MouseCursor?>(mouseCursor),
fillColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
fillColor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
return selectedFillColor;
}
return defaultFillColor;
}),
checkColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
checkColor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.focused)) {
return focusedCheckColor;
}
return defaultCheckColor;
}),
overlayColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
overlayColor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.focused)) {
return focusOverlayColor;
}
@ -207,14 +207,14 @@ void main() {
theme: ThemeData(
checkboxTheme: CheckboxThemeData(
mouseCursor: const MaterialStatePropertyAll<MouseCursor?>(themeMouseCursor),
fillColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
fillColor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
return themeSelectedFillColor;
}
return themeDefaultFillColor;
}),
checkColor: const MaterialStatePropertyAll<Color?>(themeCheckColor),
overlayColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
overlayColor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.focused)) {
return themeFocusOverlayColor;
}
@ -234,7 +234,7 @@ void main() {
value: selected,
autofocus: autofocus,
mouseCursor: mouseCursor,
fillColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
fillColor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
return selectedFillColor;
}
@ -297,7 +297,7 @@ void main() {
return MaterialApp(
theme: ThemeData(
checkboxTheme: CheckboxThemeData(
fillColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
fillColor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
return themeSelectedFillColor;
}
@ -348,7 +348,7 @@ void main() {
return MaterialApp(
theme: ThemeData(
checkboxTheme: CheckboxThemeData(
overlayColor: MaterialStateProperty.resolveWith(getOverlayColor),
overlayColor: WidgetStateProperty.resolveWith(getOverlayColor),
splashRadius: splashRadius,
),
),
@ -437,9 +437,9 @@ void main() {
test('CheckboxThemeData lerp from populated to null parameters', () {
final CheckboxThemeData theme = CheckboxThemeData(
fillColor: MaterialStateProperty.all(const Color(0xfffffff0)),
checkColor: MaterialStateProperty.all(const Color(0xfffffff1)),
overlayColor: MaterialStateProperty.all(const Color(0xfffffff2)),
fillColor: WidgetStateProperty.all(const Color(0xfffffff0)),
checkColor: WidgetStateProperty.all(const Color(0xfffffff1)),
overlayColor: WidgetStateProperty.all(const Color(0xfffffff2)),
splashRadius: 3.0,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
visualDensity: const VisualDensity(vertical: 1.0, horizontal: 1.0),
@ -464,9 +464,9 @@ void main() {
test('CheckboxThemeData lerp from null to populated parameters', () {
final CheckboxThemeData theme = CheckboxThemeData(
fillColor: MaterialStateProperty.all(const Color(0xfffffff0)),
checkColor: MaterialStateProperty.all(const Color(0xfffffff1)),
overlayColor: MaterialStateProperty.all(const Color(0xfffffff2)),
fillColor: WidgetStateProperty.all(const Color(0xfffffff0)),
checkColor: WidgetStateProperty.all(const Color(0xfffffff1)),
overlayColor: WidgetStateProperty.all(const Color(0xfffffff2)),
splashRadius: 4.0,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
visualDensity: const VisualDensity(vertical: 1.0, horizontal: 1.0),
@ -500,9 +500,9 @@ void main() {
test('CheckboxThemeData lerp from populated parameters', () {
final CheckboxThemeData themeA = CheckboxThemeData(
fillColor: MaterialStateProperty.all(const Color(0xfffffff0)),
checkColor: MaterialStateProperty.all(const Color(0xfffffff1)),
overlayColor: MaterialStateProperty.all(const Color(0xfffffff2)),
fillColor: WidgetStateProperty.all(const Color(0xfffffff0)),
checkColor: WidgetStateProperty.all(const Color(0xfffffff1)),
overlayColor: WidgetStateProperty.all(const Color(0xfffffff2)),
splashRadius: 3.0,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
visualDensity: const VisualDensity(vertical: 1.0, horizontal: 1.0),
@ -510,9 +510,9 @@ void main() {
side: const BorderSide(width: 4.0),
);
final CheckboxThemeData themeB = CheckboxThemeData(
fillColor: MaterialStateProperty.all(const Color(0xfffffff3)),
checkColor: MaterialStateProperty.all(const Color(0xfffffff4)),
overlayColor: MaterialStateProperty.all(const Color(0xfffffff5)),
fillColor: WidgetStateProperty.all(const Color(0xfffffff3)),
checkColor: WidgetStateProperty.all(const Color(0xfffffff4)),
overlayColor: WidgetStateProperty.all(const Color(0xfffffff5)),
splashRadius: 9.0,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
visualDensity: const VisualDensity(vertical: 2.0, horizontal: 2.0),

View File

@ -4887,7 +4887,7 @@ void main() {
child: RawChip(
isEnabled: enabled,
selected: selected,
color: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
color: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled) &&
states.contains(MaterialState.selected)) {
return disabledSelectedColor;

View File

@ -1102,7 +1102,7 @@ void main() {
return MaterialApp(
theme: ThemeData(
chipTheme: ChipThemeData(
color: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
color: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled) &&
states.contains(MaterialState.selected)) {
return disabledSelectedColor;

View File

@ -416,7 +416,7 @@ void main() {
const Color disabledColor = Color(0xff00ff00);
const Color backgroundColor = Color(0xff0000ff);
const Color selectedColor = Color(0xffff0000);
final MaterialStateProperty<Color?> color = MaterialStateProperty.resolveWith((
final WidgetStateProperty<Color?> color = WidgetStateProperty.resolveWith((
Set<MaterialState> states,
) {
if (states.contains(MaterialState.disabled) && states.contains(MaterialState.selected)) {

View File

@ -1355,7 +1355,7 @@ void main() {
rows: <DataRow>[
DataRow(
selected: selected,
color: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
color: WidgetStateProperty.resolveWith<Color>((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
return selectedColor;
}
@ -1395,7 +1395,7 @@ void main() {
onSelectChanged: (bool? value) {},
),
DataRow(
color: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
color: WidgetStateProperty.resolveWith<Color>((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return disabledColor;
}
@ -1431,7 +1431,7 @@ void main() {
columns: const <DataColumn>[DataColumn(label: Text('Column1'))],
rows: <DataRow>[
DataRow(
color: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
color: WidgetStateProperty.resolveWith<Color>((Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return pressedColor;
}
@ -1467,7 +1467,7 @@ void main() {
columns: const <DataColumn>[DataColumn(label: Text('Column1'))],
rows: <DataRow>[
DataRow(
color: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
color: WidgetStateProperty.resolveWith<Color>((Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return pressedColor;
}
@ -1783,7 +1783,7 @@ void main() {
rows: <DataRow>[
DataRow(
selected: selected,
color: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
color: WidgetStateProperty.resolveWith<Color>((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
return selectedColor;
}
@ -1948,7 +1948,7 @@ void main() {
columns: <DataColumn>[
// This column can be sorted.
DataColumn(
mouseCursor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
mouseCursor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return SystemMouseCursors.forbidden;
}
@ -1960,7 +1960,7 @@ void main() {
),
// This column cannot be sorted.
DataColumn(
mouseCursor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
mouseCursor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return SystemMouseCursors.forbidden;
}
@ -2014,7 +2014,7 @@ void main() {
rows: <DataRow>[
// This row can be selected.
DataRow(
mouseCursor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
mouseCursor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
return SystemMouseCursors.copy;
}
@ -2027,7 +2027,7 @@ void main() {
DataRow(
selected: true,
onSelectChanged: (bool? selected) {},
mouseCursor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
mouseCursor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
return SystemMouseCursors.copy;
}

View File

@ -84,13 +84,13 @@ void main() {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
DataTableThemeData(
decoration: const BoxDecoration(color: Color(0xfffffff0)),
dataRowColor: MaterialStateProperty.resolveWith<Color>(
dataRowColor: WidgetStateProperty.resolveWith<Color>(
(Set<MaterialState> states) => const Color(0xfffffff1),
),
dataRowMinHeight: 41.0,
dataRowMaxHeight: 42.0,
dataTextStyle: const TextStyle(fontSize: 12.0),
headingRowColor: MaterialStateProperty.resolveWith<Color>(
headingRowColor: WidgetStateProperty.resolveWith<Color>(
(Set<MaterialState> states) => const Color(0xfffffff2),
),
headingRowHeight: 52.0,
@ -128,12 +128,12 @@ void main() {
testWidgets('DataTable is themeable', (WidgetTester tester) async {
const BoxDecoration decoration = BoxDecoration(color: Color(0xfffffff0));
const MaterialStateProperty<Color> dataRowColor = MaterialStatePropertyAll<Color>(
const WidgetStateProperty<Color> dataRowColor = MaterialStatePropertyAll<Color>(
Color(0xfffffff1),
);
const double minMaxDataRowHeight = 41.0;
const TextStyle dataTextStyle = TextStyle(fontSize: 12.5);
const MaterialStateProperty<Color> headingRowColor = MaterialStatePropertyAll<Color>(
const WidgetStateProperty<Color> headingRowColor = MaterialStatePropertyAll<Color>(
Color(0xfffffff2),
);
const double headingRowHeight = 52.0;
@ -141,9 +141,9 @@ void main() {
const double horizontalMargin = 3.0;
const double columnSpacing = 4.0;
const double dividerThickness = 5.0;
const MaterialStateProperty<MouseCursor> headingCellCursor =
const WidgetStateProperty<MouseCursor> headingCellCursor =
MaterialStatePropertyAll<MouseCursor>(SystemMouseCursors.grab);
const MaterialStateProperty<MouseCursor> dataRowCursor = MaterialStatePropertyAll<MouseCursor>(
const WidgetStateProperty<MouseCursor> dataRowCursor = MaterialStatePropertyAll<MouseCursor>(
SystemMouseCursors.forbidden,
);
@ -269,12 +269,12 @@ void main() {
testWidgets('DataTable properties are taken over the theme values', (WidgetTester tester) async {
const BoxDecoration themeDecoration = BoxDecoration(color: Color(0xfffffff1));
const MaterialStateProperty<Color> themeDataRowColor = MaterialStatePropertyAll<Color>(
const WidgetStateProperty<Color> themeDataRowColor = MaterialStatePropertyAll<Color>(
Color(0xfffffff0),
);
const double minMaxThemeDataRowHeight = 50.0;
const TextStyle themeDataTextStyle = TextStyle(fontSize: 11.5);
const MaterialStateProperty<Color> themeHeadingRowColor = MaterialStatePropertyAll<Color>(
const WidgetStateProperty<Color> themeHeadingRowColor = MaterialStatePropertyAll<Color>(
Color(0xfffffff1),
);
const double themeHeadingRowHeight = 51.0;
@ -282,18 +282,18 @@ void main() {
const double themeHorizontalMargin = 2.0;
const double themeColumnSpacing = 3.0;
const double themeDividerThickness = 4.0;
const MaterialStateProperty<MouseCursor> themeHeadingCellCursor =
const WidgetStateProperty<MouseCursor> themeHeadingCellCursor =
MaterialStatePropertyAll<MouseCursor>(SystemMouseCursors.copy);
const MaterialStateProperty<MouseCursor> themeDataRowCursor =
const WidgetStateProperty<MouseCursor> themeDataRowCursor =
MaterialStatePropertyAll<MouseCursor>(SystemMouseCursors.copy);
const BoxDecoration decoration = BoxDecoration(color: Color(0xfffffff0));
const MaterialStateProperty<Color> dataRowColor = MaterialStatePropertyAll<Color>(
const WidgetStateProperty<Color> dataRowColor = MaterialStatePropertyAll<Color>(
Color(0xfffffff1),
);
const double minMaxDataRowHeight = 51.0;
const TextStyle dataTextStyle = TextStyle(fontSize: 12.5);
const MaterialStateProperty<Color> headingRowColor = MaterialStatePropertyAll<Color>(
const WidgetStateProperty<Color> headingRowColor = MaterialStatePropertyAll<Color>(
Color(0xfffffff2),
);
const double headingRowHeight = 52.0;
@ -301,9 +301,9 @@ void main() {
const double horizontalMargin = 3.0;
const double columnSpacing = 4.0;
const double dividerThickness = 5.0;
const MaterialStateProperty<MouseCursor> headingCellCursor =
const WidgetStateProperty<MouseCursor> headingCellCursor =
MaterialStatePropertyAll<MouseCursor>(SystemMouseCursors.forbidden);
const MaterialStateProperty<MouseCursor> dataRowCursor = MaterialStatePropertyAll<MouseCursor>(
const WidgetStateProperty<MouseCursor> dataRowCursor = MaterialStatePropertyAll<MouseCursor>(
SystemMouseCursors.forbidden,
);
@ -452,12 +452,12 @@ void main() {
WidgetTester tester,
) async {
const BoxDecoration globalThemeDecoration = BoxDecoration(color: Color(0xfffffff1));
const MaterialStateProperty<Color> globalThemeDataRowColor = MaterialStatePropertyAll<Color>(
const WidgetStateProperty<Color> globalThemeDataRowColor = MaterialStatePropertyAll<Color>(
Color(0xfffffff0),
);
const double minMaxGlobalThemeDataRowHeight = 50.0;
const TextStyle globalThemeDataTextStyle = TextStyle(fontSize: 11.5);
const MaterialStateProperty<Color> globalThemeHeadingRowColor = MaterialStatePropertyAll<Color>(
const WidgetStateProperty<Color> globalThemeHeadingRowColor = MaterialStatePropertyAll<Color>(
Color(0xfffffff1),
);
const double globalThemeHeadingRowHeight = 51.0;
@ -465,18 +465,18 @@ void main() {
const double globalThemeHorizontalMargin = 2.0;
const double globalThemeColumnSpacing = 3.0;
const double globalThemeDividerThickness = 4.0;
const MaterialStateProperty<MouseCursor> globalHeadingCellCursor =
const WidgetStateProperty<MouseCursor> globalHeadingCellCursor =
MaterialStatePropertyAll<MouseCursor>(SystemMouseCursors.allScroll);
const MaterialStateProperty<MouseCursor> globalDataRowCursor =
const WidgetStateProperty<MouseCursor> globalDataRowCursor =
MaterialStatePropertyAll<MouseCursor>(SystemMouseCursors.allScroll);
const BoxDecoration localThemeDecoration = BoxDecoration(color: Color(0xfffffff0));
const MaterialStateProperty<Color> localThemeDataRowColor = MaterialStatePropertyAll<Color>(
const WidgetStateProperty<Color> localThemeDataRowColor = MaterialStatePropertyAll<Color>(
Color(0xfffffff1),
);
const double minMaxLocalThemeDataRowHeight = 51.0;
const TextStyle localThemeDataTextStyle = TextStyle(fontSize: 12.5);
const MaterialStateProperty<Color> localThemeHeadingRowColor = MaterialStatePropertyAll<Color>(
const WidgetStateProperty<Color> localThemeHeadingRowColor = MaterialStatePropertyAll<Color>(
Color(0xfffffff2),
);
const double localThemeHeadingRowHeight = 52.0;
@ -484,9 +484,9 @@ void main() {
const double localThemeHorizontalMargin = 3.0;
const double localThemeColumnSpacing = 4.0;
const double localThemeDividerThickness = 5.0;
const MaterialStateProperty<MouseCursor> localHeadingCellCursor =
const WidgetStateProperty<MouseCursor> localHeadingCellCursor =
MaterialStatePropertyAll<MouseCursor>(SystemMouseCursors.move);
const MaterialStateProperty<MouseCursor> localDataRowCursor =
const WidgetStateProperty<MouseCursor> localDataRowCursor =
MaterialStatePropertyAll<MouseCursor>(SystemMouseCursors.move);
await tester.pumpWidget(

View File

@ -965,7 +965,7 @@ void main() {
testWidgets('DatePickerDialog resolves DatePickerTheme.dayOverlayColor states', (
WidgetTester tester,
) async {
final MaterialStateProperty<Color> dayOverlayColor = MaterialStateProperty.resolveWith<Color>((
final WidgetStateProperty<Color> dayOverlayColor = WidgetStateProperty.resolveWith<Color>((
Set<MaterialState> states,
) {
if (states.contains(MaterialState.hovered)) {
@ -1068,7 +1068,7 @@ void main() {
testWidgets('DatePickerDialog resolves DatePickerTheme.yearOverlayColor states', (
WidgetTester tester,
) async {
final MaterialStateProperty<Color> yearOverlayColor = MaterialStateProperty.resolveWith<Color>((
final WidgetStateProperty<Color> yearOverlayColor = WidgetStateProperty.resolveWith<Color>((
Set<MaterialState> states,
) {
if (states.contains(MaterialState.hovered)) {
@ -1147,8 +1147,8 @@ void main() {
testWidgets('DateRangePickerDialog resolves DatePickerTheme.rangeSelectionOverlayColor states', (
WidgetTester tester,
) async {
final MaterialStateProperty<Color> rangeSelectionOverlayColor =
MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
final WidgetStateProperty<Color> rangeSelectionOverlayColor =
WidgetStateProperty.resolveWith<Color>((Set<MaterialState> states) {
if (states.contains(MaterialState.hovered)) {
return const Color(0xff00ff00);
}
@ -1302,7 +1302,7 @@ void main() {
MaterialApp(
theme: ThemeData(
datePickerTheme: datePickerTheme.copyWith(
yearShape: MaterialStateProperty.all<OutlinedBorder>(yearShpae),
yearShape: WidgetStateProperty.all<OutlinedBorder>(yearShpae),
),
),
home: Directionality(

View File

@ -144,25 +144,25 @@ void main() {
const Color defaultOverlayColor = Color(0xffffff00);
final ButtonStyle customButtonStyle = ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
backgroundColor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.focused)) {
return focusedBackgroundColor;
}
return defaultBackgroundColor;
}),
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
foregroundColor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.focused)) {
return focusedForegroundColor;
}
return defaultForegroundColor;
}),
iconColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
iconColor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.focused)) {
return focusedIconColor;
}
return defaultIconColor;
}),
overlayColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
overlayColor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.focused)) {
return focusedOverlayColor;
}
@ -378,10 +378,10 @@ void main() {
const Color luckyColor = Color(0xff777777);
final ButtonStyle singleColorButtonStyle = ButtonStyle(
backgroundColor: MaterialStateProperty.all(luckyColor),
foregroundColor: MaterialStateProperty.all(luckyColor),
iconColor: MaterialStateProperty.all(luckyColor),
overlayColor: MaterialStateProperty.all(luckyColor),
backgroundColor: WidgetStateProperty.all(luckyColor),
foregroundColor: WidgetStateProperty.all(luckyColor),
iconColor: WidgetStateProperty.all(luckyColor),
overlayColor: WidgetStateProperty.all(luckyColor),
);
await tester.pumpWidget(
@ -442,8 +442,8 @@ void main() {
const Color luckyColor = Color(0xff777777);
final ButtonStyle partialButtonStyle = ButtonStyle(
backgroundColor: MaterialStateProperty.all(luckyColor),
foregroundColor: MaterialStateProperty.all(luckyColor),
backgroundColor: WidgetStateProperty.all(luckyColor),
foregroundColor: WidgetStateProperty.all(luckyColor),
);
final List<DropdownMenuEntry<TestMenu>> partiallyStyledMenuEntries =

View File

@ -468,7 +468,7 @@ void main() {
child: ElevatedButtonTheme(
data: ElevatedButtonThemeData(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.resolveWith<Color>(getTextColor),
foregroundColor: WidgetStateProperty.resolveWith<Color>(getTextColor),
),
),
child: Builder(
@ -544,8 +544,8 @@ void main() {
child: ElevatedButtonTheme(
data: ElevatedButtonThemeData(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.resolveWith<Color>(getTextColor),
iconColor: MaterialStateProperty.resolveWith<Color>(getTextColor),
foregroundColor: WidgetStateProperty.resolveWith<Color>(getTextColor),
iconColor: WidgetStateProperty.resolveWith<Color>(getTextColor),
),
),
child: Builder(
@ -863,7 +863,7 @@ void main() {
textDirection: TextDirection.ltr,
child: ElevatedButton(
style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
overlayColor: WidgetStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
return states.contains(MaterialState.hovered) ? hoverColor : null;
}),
),
@ -893,7 +893,7 @@ void main() {
textDirection: TextDirection.ltr,
child: ElevatedButton(
style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
overlayColor: WidgetStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
return states.contains(MaterialState.focused) ? focusColor : null;
}),
),
@ -930,7 +930,7 @@ void main() {
child: ElevatedButton(
autofocus: true,
style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color?>(getOverlayColor),
overlayColor: WidgetStateProperty.resolveWith<Color?>(getOverlayColor),
),
focusNode: focusNode,
onPressed: () {},

View File

@ -194,11 +194,11 @@ void main() {
expect(material.shadowColor, shadowColor);
expect(material.elevation, elevation);
expect(
MaterialStateProperty.resolveAs<MouseCursor>(inkWell.mouseCursor!, enabled),
WidgetStateProperty.resolveAs<MouseCursor>(inkWell.mouseCursor!, enabled),
enabledMouseCursor,
);
expect(
MaterialStateProperty.resolveAs<MouseCursor>(inkWell.mouseCursor!, disabled),
WidgetStateProperty.resolveAs<MouseCursor>(inkWell.mouseCursor!, disabled),
disabledMouseCursor,
);
expect(inkWell.overlayColor!.resolve(hovered), foregroundColor.withOpacity(0.08));

View File

@ -655,7 +655,7 @@ void main() {
child: FilledButtonTheme(
data: FilledButtonThemeData(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.resolveWith<Color>(getTextColor),
foregroundColor: WidgetStateProperty.resolveWith<Color>(getTextColor),
),
),
child: Builder(
@ -730,8 +730,8 @@ void main() {
child: FilledButtonTheme(
data: FilledButtonThemeData(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.resolveWith<Color>(getTextColor),
iconColor: MaterialStateProperty.resolveWith<Color>(getTextColor),
foregroundColor: WidgetStateProperty.resolveWith<Color>(getTextColor),
iconColor: WidgetStateProperty.resolveWith<Color>(getTextColor),
),
),
child: Builder(
@ -1045,7 +1045,7 @@ void main() {
textDirection: TextDirection.ltr,
child: FilledButton(
style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
overlayColor: WidgetStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
return states.contains(MaterialState.hovered) ? hoverColor : null;
}),
),
@ -1075,7 +1075,7 @@ void main() {
textDirection: TextDirection.ltr,
child: FilledButton(
style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
overlayColor: WidgetStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
return states.contains(MaterialState.focused) ? focusColor : null;
}),
),
@ -1111,7 +1111,7 @@ void main() {
child: FilledButton(
autofocus: true,
style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color?>(getOverlayColor),
overlayColor: WidgetStateProperty.resolveWith<Color?>(getOverlayColor),
),
focusNode: focusNode,
onPressed: () {},

View File

@ -151,11 +151,11 @@ void main() {
expect(material.shadowColor, shadowColor);
expect(material.elevation, elevation);
expect(
MaterialStateProperty.resolveAs<MouseCursor>(inkWell.mouseCursor!, enabled),
WidgetStateProperty.resolveAs<MouseCursor>(inkWell.mouseCursor!, enabled),
enabledMouseCursor,
);
expect(
MaterialStateProperty.resolveAs<MouseCursor>(inkWell.mouseCursor!, disabled),
WidgetStateProperty.resolveAs<MouseCursor>(inkWell.mouseCursor!, disabled),
disabledMouseCursor,
);
expect(inkWell.overlayColor!.resolve(hovered), foregroundColor.withOpacity(0.08));

View File

@ -471,7 +471,7 @@ void main() {
const Color disabledColor = Color(0xff00ff00);
const Color backgroundColor = Color(0xff0000ff);
const Color selectedColor = Color(0xffff0000);
final MaterialStateProperty<Color?> color = MaterialStateProperty.resolveWith((
final WidgetStateProperty<Color?> color = WidgetStateProperty.resolveWith((
Set<MaterialState> states,
) {
if (states.contains(MaterialState.disabled) && states.contains(MaterialState.selected)) {

View File

@ -547,7 +547,7 @@ void main() {
MaterialApp(
theme: ThemeData().copyWith(
floatingActionButtonTheme: FloatingActionButtonThemeData(
mouseCursor: MaterialStateProperty.all(SystemMouseCursors.text),
mouseCursor: WidgetStateProperty.all(SystemMouseCursors.text),
),
),
home: Scaffold(

View File

@ -2133,7 +2133,7 @@ void main() {
body: Center(
child: IconButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.resolveWith<Color>(getIconColor),
foregroundColor: WidgetStateProperty.resolveWith<Color>(getIconColor),
),
isSelected: isSelected,
onPressed: () {

View File

@ -145,11 +145,11 @@ void main() {
expect(material.shadowColor, shadowColor);
expect(material.elevation, elevation);
expect(
MaterialStateProperty.resolveAs<MouseCursor?>(inkWell.mouseCursor, enabled),
WidgetStateProperty.resolveAs<MouseCursor?>(inkWell.mouseCursor, enabled),
enabledMouseCursor,
);
expect(
MaterialStateProperty.resolveAs<MouseCursor?>(inkWell.mouseCursor, disabled),
WidgetStateProperty.resolveAs<MouseCursor?>(inkWell.mouseCursor, disabled),
disabledMouseCursor,
);
expect(inkWell.overlayColor!.resolve(hovered), foregroundColor.withOpacity(0.08));

View File

@ -236,7 +236,7 @@ void main() {
width: 100,
height: 100,
child: InkWell(
overlayColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
overlayColor: WidgetStateProperty.resolveWith<Color>((Set<MaterialState> states) {
if (states.contains(MaterialState.hovered)) {
return const Color(0xff00ff00);
}
@ -329,7 +329,7 @@ void main() {
height: 100,
child: InkWell(
focusNode: focusNode,
overlayColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
overlayColor: WidgetStateProperty.resolveWith<Color>((Set<MaterialState> states) {
if (states.contains(MaterialState.hovered)) {
return const Color(0xff00ff00);
}
@ -381,7 +381,7 @@ void main() {
height: 100,
child: InkWell(
splashFactory: NoSplash.splashFactory,
overlayColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
overlayColor: WidgetStateProperty.resolveWith<Color>((Set<MaterialState> states) {
if (states.contains(MaterialState.pressed)) {
return pressedColor;
}
@ -571,7 +571,7 @@ void main() {
width: 100,
height: 100,
child: InkWell(
overlayColor: MaterialStateProperty.resolveWith<Color>((
overlayColor: WidgetStateProperty.resolveWith<Color>((
Set<MaterialState> states,
) {
if (states.contains(MaterialState.hovered)) {
@ -2420,9 +2420,7 @@ void main() {
width: 100,
height: 100,
child: InkWell(
overlayColor: MaterialStateProperty.resolveWith<Color?>((
Set<MaterialState> states,
) {
overlayColor: WidgetStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
if (states.contains(MaterialState.hovered)) {
return const Color(0xff00ff00);
}

View File

@ -128,7 +128,7 @@ void main() {
child: InputChip(
onSelected: enabled ? (bool value) {} : null,
selected: selected,
color: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
color: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled) &&
states.contains(MaterialState.selected)) {
return disabledSelectedColor;

View File

@ -10125,7 +10125,7 @@ void main() {
const Color iconErrorColor = Color(0xffff0000);
const Color iconColor = Color(0xff00ff00);
final ButtonStyle iconButtonStyle = ButtonStyle(
foregroundColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
foregroundColor: WidgetStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
if (states.contains(MaterialState.error)) {
return iconErrorColor;
}
@ -10167,7 +10167,7 @@ void main() {
const Color iconErrorColor = Color(0xffff0000);
const Color iconColor = Color(0xff00ff00);
final ButtonStyle iconButtonStyle = ButtonStyle(
foregroundColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
foregroundColor: WidgetStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
if (states.contains(MaterialState.error)) {
return iconErrorColor;
}

View File

@ -230,7 +230,7 @@ void main() {
iconColor: iconColor,
textColor: textColor,
minVerticalPadding: 25.0,
mouseCursor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
mouseCursor: WidgetStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return SystemMouseCursors.forbidden;
}

View File

@ -506,7 +506,7 @@ void main() {
menuChildren: <Widget>[
MenuItemButton(
style: ButtonStyle(
minimumSize: MaterialStateProperty.all<Size>(const Size.fromHeight(1000)),
minimumSize: WidgetStateProperty.all<Size>(const Size.fromHeight(1000)),
),
onPressed: () {},
child: const Text('Category'),
@ -544,7 +544,7 @@ void main() {
menuChildren: <Widget>[
MenuItemButton(
style: ButtonStyle(
minimumSize: MaterialStateProperty.all<Size>(const Size.fromHeight(1000)),
minimumSize: WidgetStateProperty.all<Size>(const Size.fromHeight(1000)),
),
onPressed: () {},
child: const Text('Category'),
@ -1097,7 +1097,7 @@ void main() {
Expanded(
child: MenuBar(
style: MenuStyle(
elevation: MaterialStateProperty.all<double?>(10),
elevation: WidgetStateProperty.all<double?>(10),
backgroundColor: const MaterialStatePropertyAll<Color>(Colors.red),
),
children: createTestMenus(onPressed: onPressed),
@ -2992,13 +2992,13 @@ void main() {
testWidgets('diagnostics', (WidgetTester tester) async {
final ButtonStyle style = ButtonStyle(
shape: MaterialStateProperty.all<OutlinedBorder?>(const StadiumBorder()),
elevation: MaterialStateProperty.all<double?>(10.0),
shape: WidgetStateProperty.all<OutlinedBorder?>(const StadiumBorder()),
elevation: WidgetStateProperty.all<double?>(10.0),
backgroundColor: const MaterialStatePropertyAll<Color>(Colors.red),
);
final MenuStyle menuStyle = MenuStyle(
shape: MaterialStateProperty.all<OutlinedBorder?>(const RoundedRectangleBorder()),
elevation: MaterialStateProperty.all<double?>(20.0),
shape: WidgetStateProperty.all<OutlinedBorder?>(const RoundedRectangleBorder()),
elevation: WidgetStateProperty.all<double?>(20.0),
backgroundColor: const MaterialStatePropertyAll<Color>(Colors.green),
);
await tester.pumpWidget(

View File

@ -1086,7 +1086,7 @@ void main() {
const Color hoverColor = Color(0xff0000ff);
const Color focusColor = Color(0xff00ffff);
const Color pressedColor = Color(0xffff00ff);
final MaterialStateProperty<Color?> overlayColor = MaterialStateProperty.resolveWith<Color>((
final WidgetStateProperty<Color?> overlayColor = WidgetStateProperty.resolveWith<Color>((
Set<MaterialState> states,
) {
if (states.contains(MaterialState.hovered)) {