diff --git a/dev/tools/gen_defaults/lib/date_picker_template.dart b/dev/tools/gen_defaults/lib/date_picker_template.dart index 6666a8fc44..ae8c3861b5 100644 --- a/dev/tools/gen_defaults/lib/date_picker_template.dart +++ b/dev/tools/gen_defaults/lib/date_picker_template.dart @@ -49,7 +49,7 @@ class _${blockName}DefaultsM3 extends DatePickerThemeData { shape: ${shape("md.comp.date-picker.modal.container")}, // TODO(tahatesser): Update this to use token when gen_defaults // supports `CircleBorder` for fully rounded corners. - dayShape: const MaterialStatePropertyAll(CircleBorder()), + dayShape: const WidgetStatePropertyAll(CircleBorder()), rangePickerElevation: ${elevation("md.comp.date-picker.modal.range-selection.container")}, rangePickerShape: ${shape("md.comp.date-picker.modal.range-selection.container")}, ); @@ -99,46 +99,46 @@ class _${blockName}DefaultsM3 extends DatePickerThemeData { TextStyle? get dayStyle => ${textStyle("md.comp.date-picker.modal.date.label-text")}; @override - MaterialStateProperty? get dayForegroundColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { + WidgetStateProperty? get dayForegroundColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { return ${componentColor('md.comp.date-picker.modal.date.selected.label-text')}; - } else if (states.contains(MaterialState.disabled)) { + } else if (states.contains(WidgetState.disabled)) { return ${componentColor('md.comp.date-picker.modal.date.unselected.label-text')}.withOpacity(0.38); } return ${componentColor('md.comp.date-picker.modal.date.unselected.label-text')}; }); @override - MaterialStateProperty? get dayBackgroundColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { + WidgetStateProperty? get dayBackgroundColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { return ${componentColor('md.comp.date-picker.modal.date.selected.container')}; } return ${componentColor('md.comp.date-picker.modal.date.unselected.container')}; }); @override - MaterialStateProperty? get dayOverlayColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { - if (states.contains(MaterialState.pressed)) { + WidgetStateProperty? get dayOverlayColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { + if (states.contains(WidgetState.pressed)) { return ${_stateColor('md.comp.date-picker.modal.date', 'selected', 'pressed')}; } - if (states.contains(MaterialState.hovered)) { + if (states.contains(WidgetState.hovered)) { return ${_stateColor('md.comp.date-picker.modal.date', 'selected', 'hover')}; } - if (states.contains(MaterialState.focused)) { + if (states.contains(WidgetState.focused)) { return ${_stateColor('md.comp.date-picker.modal.date', 'selected', 'focus')}; } } else { - if (states.contains(MaterialState.pressed)) { + if (states.contains(WidgetState.pressed)) { return ${_stateColor('md.comp.date-picker.modal.date', 'unselected', 'pressed')}; } - if (states.contains(MaterialState.hovered)) { + if (states.contains(WidgetState.hovered)) { return ${_stateColor('md.comp.date-picker.modal.date', 'unselected', 'hover')}; } - if (states.contains(MaterialState.focused)) { + if (states.contains(WidgetState.focused)) { return ${_stateColor('md.comp.date-picker.modal.date', 'unselected', 'focus')}; } } @@ -146,18 +146,18 @@ class _${blockName}DefaultsM3 extends DatePickerThemeData { }); @override - MaterialStateProperty? get todayForegroundColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { + WidgetStateProperty? get todayForegroundColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { return ${componentColor('md.comp.date-picker.modal.date.selected.label-text')}; - } else if (states.contains(MaterialState.disabled)) { + } else if (states.contains(WidgetState.disabled)) { return ${componentColor('md.comp.date-picker.modal.date.today.label-text')}.withOpacity(0.38); } return ${componentColor('md.comp.date-picker.modal.date.today.label-text')}; }); @override - MaterialStateProperty? get todayBackgroundColor => dayBackgroundColor; + WidgetStateProperty? get todayBackgroundColor => dayBackgroundColor; @override BorderSide? get todayBorder => ${border('md.comp.date-picker.modal.date.today.container.outline')}; @@ -166,46 +166,46 @@ class _${blockName}DefaultsM3 extends DatePickerThemeData { TextStyle? get yearStyle => ${textStyle("md.comp.date-picker.modal.year-selection.year.label-text")}; @override - MaterialStateProperty? get yearForegroundColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { + WidgetStateProperty? get yearForegroundColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { return ${componentColor('md.comp.date-picker.modal.year-selection.year.selected.label-text')}; - } else if (states.contains(MaterialState.disabled)) { + } else if (states.contains(WidgetState.disabled)) { return ${componentColor('md.comp.date-picker.modal.year-selection.year.unselected.label-text')}.withOpacity(0.38); } return ${componentColor('md.comp.date-picker.modal.year-selection.year.unselected.label-text')}; }); @override - MaterialStateProperty? get yearBackgroundColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { + WidgetStateProperty? get yearBackgroundColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { return ${componentColor('md.comp.date-picker.modal.year-selection.year.selected.container')}; } return ${componentColor('md.comp.date-picker.modal.year-selection.year.unselected.container')}; }); @override - MaterialStateProperty? get yearOverlayColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { - if (states.contains(MaterialState.pressed)) { + WidgetStateProperty? get yearOverlayColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { + if (states.contains(WidgetState.pressed)) { return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'selected', 'pressed')}; } - if (states.contains(MaterialState.hovered)) { + if (states.contains(WidgetState.hovered)) { return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'selected', 'hover')}; } - if (states.contains(MaterialState.focused)) { + if (states.contains(WidgetState.focused)) { return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'selected', 'focus')}; } } else { - if (states.contains(MaterialState.pressed)) { + if (states.contains(WidgetState.pressed)) { return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'unselected', 'pressed')}; } - if (states.contains(MaterialState.hovered)) { + if (states.contains(WidgetState.hovered)) { return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'unselected', 'hover')}; } - if (states.contains(MaterialState.focused)) { + if (states.contains(WidgetState.focused)) { return ${_stateColor('md.comp.date-picker.modal.year-selection.year', 'unselected', 'focus')}; } } @@ -222,15 +222,15 @@ class _${blockName}DefaultsM3 extends DatePickerThemeData { Color? get rangeSelectionBackgroundColor => ${colorOrTransparent("md.comp.date-picker.modal.range-selection.active-indicator.container.color")}; @override - MaterialStateProperty? get rangeSelectionOverlayColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.pressed)) { + WidgetStateProperty? get rangeSelectionOverlayColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.pressed)) { return ${_stateColor('md.comp.date-picker.modal.range-selection.date.in-range', null, 'pressed')}; } - if (states.contains(MaterialState.hovered)) { + if (states.contains(WidgetState.hovered)) { return ${_stateColor('md.comp.date-picker.modal.range-selection.date.in-range', null, 'hover')}; } - if (states.contains(MaterialState.focused)) { + if (states.contains(WidgetState.focused)) { return ${_stateColor('md.comp.date-picker.modal.range-selection.date.in-range', null, 'focus')}; } return null; diff --git a/packages/flutter/lib/src/material/date_picker.dart b/packages/flutter/lib/src/material/date_picker.dart index 3b94e1720d..bc28ca3979 100644 --- a/packages/flutter/lib/src/material/date_picker.dart +++ b/packages/flutter/lib/src/material/date_picker.dart @@ -33,7 +33,6 @@ import 'input_date_picker_form_field.dart'; import 'input_decorator.dart'; import 'material.dart'; import 'material_localizations.dart'; -import 'material_state.dart'; import 'scaffold.dart'; import 'text_button.dart'; import 'text_field.dart'; @@ -2828,7 +2827,7 @@ class _DayItem extends StatefulWidget { } class _DayItemState extends State<_DayItem> { - final MaterialStatesController _statesController = MaterialStatesController(); + final WidgetStatesController _statesController = WidgetStatesController(); @override void dispose() { @@ -2855,17 +2854,17 @@ class _DayItemState extends State<_DayItem> { } T? resolve( - MaterialStateProperty? Function(DatePickerThemeData? theme) getProperty, - Set states, + WidgetStateProperty? Function(DatePickerThemeData? theme) getProperty, + Set states, ) { return effectiveValue((DatePickerThemeData? theme) { return getProperty(theme)?.resolve(states); }); } - final Set states = { - if (widget.isDisabled) MaterialState.disabled, - if (widget.isSelectedDayStart || widget.isSelectedDayEnd) MaterialState.selected, + final Set states = { + if (widget.isDisabled) WidgetState.disabled, + if (widget.isSelectedDayStart || widget.isSelectedDayEnd) WidgetState.selected, }; _statesController.value = states; @@ -2878,8 +2877,8 @@ class _DayItemState extends State<_DayItem> { (DatePickerThemeData? theme) => theme?.dayBackgroundColor, states, ); - final MaterialStateProperty dayOverlayColor = MaterialStateProperty.resolveWith( - (Set states) => effectiveValue( + final WidgetStateProperty dayOverlayColor = WidgetStateProperty.resolveWith( + (Set states) => effectiveValue( (DatePickerThemeData? theme) => widget.isInRange ? theme?.rangeSelectionOverlayColor?.resolve(states) diff --git a/packages/flutter/lib/src/material/date_picker_theme.dart b/packages/flutter/lib/src/material/date_picker_theme.dart index 7cba3dc4cd..855269c34c 100644 --- a/packages/flutter/lib/src/material/date_picker_theme.dart +++ b/packages/flutter/lib/src/material/date_picker_theme.dart @@ -19,7 +19,6 @@ import 'button_style.dart'; import 'color_scheme.dart'; import 'colors.dart'; import 'input_decorator.dart'; -import 'material_state.dart'; import 'text_button.dart'; import 'text_theme.dart'; import 'theme.dart'; @@ -163,15 +162,15 @@ class DatePickerThemeData with Diagnosticable { /// grid of the date picker. /// /// This will be used instead of the color provided in [dayStyle]. - final MaterialStateProperty? dayForegroundColor; + final WidgetStateProperty? dayForegroundColor; /// Overrides the default color used to paint the background of the /// day labels in the grid of the date picker. - final MaterialStateProperty? dayBackgroundColor; + final WidgetStateProperty? dayBackgroundColor; /// Overrides the default highlight color that's typically used to /// indicate that a day in the grid is focused, hovered, or pressed. - final MaterialStateProperty? dayOverlayColor; + final WidgetStateProperty? dayOverlayColor; /// Overrides the default shape used to paint the shape decoration of the /// day labels in the grid of the date picker. @@ -192,7 +191,7 @@ class DatePickerThemeData with Diagnosticable { /// /// ** See code in examples/api/lib/material/date_picker/date_picker_theme_day_shape.0.dart ** /// {@end-tool} - final MaterialStateProperty? dayShape; + final WidgetStateProperty? dayShape; /// Overrides the default color used to paint the /// [DatePickerDialog.currentDate] label in the grid of the dialog's @@ -208,11 +207,11 @@ class DatePickerThemeData with Diagnosticable { /// /// ** See code in examples/api/lib/material/date_picker/date_picker_theme_day_shape.0.dart ** /// {@end-tool} - final MaterialStateProperty? todayForegroundColor; + final WidgetStateProperty? todayForegroundColor; /// Overrides the default color used to paint the background of the /// [DatePickerDialog.currentDate] label in the grid of the date picker. - final MaterialStateProperty? todayBackgroundColor; + final WidgetStateProperty? todayBackgroundColor; /// Overrides the border used to paint the /// [DatePickerDialog.currentDate] label in the grid of the date @@ -241,16 +240,16 @@ class DatePickerThemeData with Diagnosticable { /// selector of the date picker. /// /// This will be used instead of the color provided in [yearStyle]. - final MaterialStateProperty? yearForegroundColor; + final WidgetStateProperty? yearForegroundColor; /// Overrides the default color used to paint the background of the /// year labels in the year selector of the of the date picker. - final MaterialStateProperty? yearBackgroundColor; + final WidgetStateProperty? yearBackgroundColor; /// Overrides the default highlight color that's typically used to /// indicate that a year in the year selector is focused, hovered, /// or pressed. - final MaterialStateProperty? yearOverlayColor; + final WidgetStateProperty? yearOverlayColor; /// Overrides the default [Scaffold.backgroundColor] for /// [DateRangePickerDialog]. @@ -339,7 +338,7 @@ class DatePickerThemeData with Diagnosticable { /// Overrides the default highlight color that's typically used to /// indicate that a date in the selected range of a /// [DateRangePickerDialog] is focused, hovered, or pressed. - final MaterialStateProperty? rangeSelectionOverlayColor; + final WidgetStateProperty? rangeSelectionOverlayColor; /// Overrides the default color used to paint the horizontal divider /// below the header text when dialog is in portrait orientation @@ -374,17 +373,17 @@ class DatePickerThemeData with Diagnosticable { TextStyle? headerHelpStyle, TextStyle? weekdayStyle, TextStyle? dayStyle, - MaterialStateProperty? dayForegroundColor, - MaterialStateProperty? dayBackgroundColor, - MaterialStateProperty? dayOverlayColor, - MaterialStateProperty? dayShape, - MaterialStateProperty? todayForegroundColor, - MaterialStateProperty? todayBackgroundColor, + WidgetStateProperty? dayForegroundColor, + WidgetStateProperty? dayBackgroundColor, + WidgetStateProperty? dayOverlayColor, + WidgetStateProperty? dayShape, + WidgetStateProperty? todayForegroundColor, + WidgetStateProperty? todayBackgroundColor, BorderSide? todayBorder, TextStyle? yearStyle, - MaterialStateProperty? yearForegroundColor, - MaterialStateProperty? yearBackgroundColor, - MaterialStateProperty? yearOverlayColor, + WidgetStateProperty? yearForegroundColor, + WidgetStateProperty? yearBackgroundColor, + WidgetStateProperty? yearOverlayColor, Color? rangePickerBackgroundColor, double? rangePickerElevation, Color? rangePickerShadowColor, @@ -395,7 +394,7 @@ class DatePickerThemeData with Diagnosticable { TextStyle? rangePickerHeaderHeadlineStyle, TextStyle? rangePickerHeaderHelpStyle, Color? rangeSelectionBackgroundColor, - MaterialStateProperty? rangeSelectionOverlayColor, + WidgetStateProperty? rangeSelectionOverlayColor, Color? dividerColor, InputDecorationTheme? inputDecorationTheme, ButtonStyle? cancelButtonStyle, @@ -465,37 +464,37 @@ class DatePickerThemeData with Diagnosticable { headerHelpStyle: TextStyle.lerp(a?.headerHelpStyle, b?.headerHelpStyle, t), weekdayStyle: TextStyle.lerp(a?.weekdayStyle, b?.weekdayStyle, t), dayStyle: TextStyle.lerp(a?.dayStyle, b?.dayStyle, t), - dayForegroundColor: MaterialStateProperty.lerp( + dayForegroundColor: WidgetStateProperty.lerp( a?.dayForegroundColor, b?.dayForegroundColor, t, Color.lerp, ), - dayBackgroundColor: MaterialStateProperty.lerp( + dayBackgroundColor: WidgetStateProperty.lerp( a?.dayBackgroundColor, b?.dayBackgroundColor, t, Color.lerp, ), - dayOverlayColor: MaterialStateProperty.lerp( + dayOverlayColor: WidgetStateProperty.lerp( a?.dayOverlayColor, b?.dayOverlayColor, t, Color.lerp, ), - dayShape: MaterialStateProperty.lerp( + dayShape: WidgetStateProperty.lerp( a?.dayShape, b?.dayShape, t, OutlinedBorder.lerp, ), - todayForegroundColor: MaterialStateProperty.lerp( + todayForegroundColor: WidgetStateProperty.lerp( a?.todayForegroundColor, b?.todayForegroundColor, t, Color.lerp, ), - todayBackgroundColor: MaterialStateProperty.lerp( + todayBackgroundColor: WidgetStateProperty.lerp( a?.todayBackgroundColor, b?.todayBackgroundColor, t, @@ -503,19 +502,19 @@ class DatePickerThemeData with Diagnosticable { ), todayBorder: _lerpBorderSide(a?.todayBorder, b?.todayBorder, t), yearStyle: TextStyle.lerp(a?.yearStyle, b?.yearStyle, t), - yearForegroundColor: MaterialStateProperty.lerp( + yearForegroundColor: WidgetStateProperty.lerp( a?.yearForegroundColor, b?.yearForegroundColor, t, Color.lerp, ), - yearBackgroundColor: MaterialStateProperty.lerp( + yearBackgroundColor: WidgetStateProperty.lerp( a?.yearBackgroundColor, b?.yearBackgroundColor, t, Color.lerp, ), - yearOverlayColor: MaterialStateProperty.lerp( + yearOverlayColor: WidgetStateProperty.lerp( a?.yearOverlayColor, b?.yearOverlayColor, t, @@ -559,7 +558,7 @@ class DatePickerThemeData with Diagnosticable { b?.rangeSelectionBackgroundColor, t, ), - rangeSelectionOverlayColor: MaterialStateProperty.lerp( + rangeSelectionOverlayColor: WidgetStateProperty.lerp( a?.rangeSelectionOverlayColor, b?.rangeSelectionOverlayColor, t, @@ -700,42 +699,42 @@ class DatePickerThemeData with Diagnosticable { ); properties.add(DiagnosticsProperty('dayStyle', dayStyle, defaultValue: null)); properties.add( - DiagnosticsProperty>( + DiagnosticsProperty>( 'dayForegroundColor', dayForegroundColor, defaultValue: null, ), ); properties.add( - DiagnosticsProperty>( + DiagnosticsProperty>( 'dayBackgroundColor', dayBackgroundColor, defaultValue: null, ), ); properties.add( - DiagnosticsProperty>( + DiagnosticsProperty>( 'dayOverlayColor', dayOverlayColor, defaultValue: null, ), ); properties.add( - DiagnosticsProperty>( + DiagnosticsProperty>( 'dayShape', dayShape, defaultValue: null, ), ); properties.add( - DiagnosticsProperty>( + DiagnosticsProperty>( 'todayForegroundColor', todayForegroundColor, defaultValue: null, ), ); properties.add( - DiagnosticsProperty>( + DiagnosticsProperty>( 'todayBackgroundColor', todayBackgroundColor, defaultValue: null, @@ -746,21 +745,21 @@ class DatePickerThemeData with Diagnosticable { ); properties.add(DiagnosticsProperty('yearStyle', yearStyle, defaultValue: null)); properties.add( - DiagnosticsProperty>( + DiagnosticsProperty>( 'yearForegroundColor', yearForegroundColor, defaultValue: null, ), ); properties.add( - DiagnosticsProperty>( + DiagnosticsProperty>( 'yearBackgroundColor', yearBackgroundColor, defaultValue: null, ), ); properties.add( - DiagnosticsProperty>( + DiagnosticsProperty>( 'yearOverlayColor', yearOverlayColor, defaultValue: null, @@ -817,7 +816,7 @@ class DatePickerThemeData with Diagnosticable { ), ); properties.add( - DiagnosticsProperty>( + DiagnosticsProperty>( 'rangeSelectionOverlayColor', rangeSelectionOverlayColor, defaultValue: null, @@ -943,7 +942,7 @@ class _DatePickerDefaultsM2 extends DatePickerThemeData { : super( elevation: 24.0, shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(4.0))), - dayShape: const MaterialStatePropertyAll(CircleBorder()), + dayShape: const WidgetStatePropertyAll(CircleBorder()), rangePickerElevation: 0.0, rangePickerShape: const RoundedRectangleBorder(), ); @@ -984,46 +983,46 @@ class _DatePickerDefaultsM2 extends DatePickerThemeData { TextStyle? get dayStyle => _textTheme.bodySmall; @override - MaterialStateProperty? get dayForegroundColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { + WidgetStateProperty? get dayForegroundColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { return _colors.onPrimary; - } else if (states.contains(MaterialState.disabled)) { + } else if (states.contains(WidgetState.disabled)) { return _colors.onSurface.withOpacity(0.38); } return _colors.onSurface; }); @override - MaterialStateProperty? get dayBackgroundColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { + WidgetStateProperty? get dayBackgroundColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { return _colors.primary; } return null; }); @override - MaterialStateProperty? get dayOverlayColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { - if (states.contains(MaterialState.pressed)) { + WidgetStateProperty? get dayOverlayColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { + if (states.contains(WidgetState.pressed)) { return _colors.onPrimary.withOpacity(0.38); } - if (states.contains(MaterialState.hovered)) { + if (states.contains(WidgetState.hovered)) { return _colors.onPrimary.withOpacity(0.08); } - if (states.contains(MaterialState.focused)) { + if (states.contains(WidgetState.focused)) { return _colors.onPrimary.withOpacity(0.12); } } else { - if (states.contains(MaterialState.pressed)) { + if (states.contains(WidgetState.pressed)) { return _colors.onSurfaceVariant.withOpacity(0.12); } - if (states.contains(MaterialState.hovered)) { + if (states.contains(WidgetState.hovered)) { return _colors.onSurfaceVariant.withOpacity(0.08); } - if (states.contains(MaterialState.focused)) { + if (states.contains(WidgetState.focused)) { return _colors.onSurfaceVariant.withOpacity(0.12); } } @@ -1031,18 +1030,18 @@ class _DatePickerDefaultsM2 extends DatePickerThemeData { }); @override - MaterialStateProperty? get todayForegroundColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { + WidgetStateProperty? get todayForegroundColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { return _colors.onPrimary; - } else if (states.contains(MaterialState.disabled)) { + } else if (states.contains(WidgetState.disabled)) { return _colors.onSurface.withOpacity(0.38); } return _colors.primary; }); @override - MaterialStateProperty? get todayBackgroundColor => dayBackgroundColor; + WidgetStateProperty? get todayBackgroundColor => dayBackgroundColor; @override BorderSide? get todayBorder => BorderSide(color: _colors.primary); @@ -1075,26 +1074,26 @@ class _DatePickerDefaultsM2 extends DatePickerThemeData { Color? get rangeSelectionBackgroundColor => _colors.primary.withOpacity(0.12); @override - MaterialStateProperty? get rangeSelectionOverlayColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { - if (states.contains(MaterialState.pressed)) { + WidgetStateProperty? get rangeSelectionOverlayColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { + if (states.contains(WidgetState.pressed)) { return _colors.onPrimary.withOpacity(0.38); } - if (states.contains(MaterialState.hovered)) { + if (states.contains(WidgetState.hovered)) { return _colors.onPrimary.withOpacity(0.08); } - if (states.contains(MaterialState.focused)) { + if (states.contains(WidgetState.focused)) { return _colors.onPrimary.withOpacity(0.12); } } else { - if (states.contains(MaterialState.pressed)) { + if (states.contains(WidgetState.pressed)) { return _colors.onSurfaceVariant.withOpacity(0.12); } - if (states.contains(MaterialState.hovered)) { + if (states.contains(WidgetState.hovered)) { return _colors.onSurfaceVariant.withOpacity(0.08); } - if (states.contains(MaterialState.focused)) { + if (states.contains(WidgetState.focused)) { return _colors.onSurfaceVariant.withOpacity(0.12); } } @@ -1117,7 +1116,7 @@ class _DatePickerDefaultsM3 extends DatePickerThemeData { shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(28.0))), // TODO(tahatesser): Update this to use token when gen_defaults // supports `CircleBorder` for fully rounded corners. - dayShape: const MaterialStatePropertyAll(CircleBorder()), + dayShape: const WidgetStatePropertyAll(CircleBorder()), rangePickerElevation: 0.0, rangePickerShape: const RoundedRectangleBorder(), ); @@ -1167,46 +1166,46 @@ class _DatePickerDefaultsM3 extends DatePickerThemeData { TextStyle? get dayStyle => _textTheme.bodyLarge; @override - MaterialStateProperty? get dayForegroundColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { + WidgetStateProperty? get dayForegroundColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { return _colors.onPrimary; - } else if (states.contains(MaterialState.disabled)) { + } else if (states.contains(WidgetState.disabled)) { return _colors.onSurface.withOpacity(0.38); } return _colors.onSurface; }); @override - MaterialStateProperty? get dayBackgroundColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { + WidgetStateProperty? get dayBackgroundColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { return _colors.primary; } return null; }); @override - MaterialStateProperty? get dayOverlayColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { - if (states.contains(MaterialState.pressed)) { + WidgetStateProperty? get dayOverlayColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { + if (states.contains(WidgetState.pressed)) { return _colors.onPrimary.withOpacity(0.1); } - if (states.contains(MaterialState.hovered)) { + if (states.contains(WidgetState.hovered)) { return _colors.onPrimary.withOpacity(0.08); } - if (states.contains(MaterialState.focused)) { + if (states.contains(WidgetState.focused)) { return _colors.onPrimary.withOpacity(0.1); } } else { - if (states.contains(MaterialState.pressed)) { + if (states.contains(WidgetState.pressed)) { return _colors.onSurfaceVariant.withOpacity(0.1); } - if (states.contains(MaterialState.hovered)) { + if (states.contains(WidgetState.hovered)) { return _colors.onSurfaceVariant.withOpacity(0.08); } - if (states.contains(MaterialState.focused)) { + if (states.contains(WidgetState.focused)) { return _colors.onSurfaceVariant.withOpacity(0.1); } } @@ -1214,18 +1213,18 @@ class _DatePickerDefaultsM3 extends DatePickerThemeData { }); @override - MaterialStateProperty? get todayForegroundColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { + WidgetStateProperty? get todayForegroundColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { return _colors.onPrimary; - } else if (states.contains(MaterialState.disabled)) { + } else if (states.contains(WidgetState.disabled)) { return _colors.primary.withOpacity(0.38); } return _colors.primary; }); @override - MaterialStateProperty? get todayBackgroundColor => dayBackgroundColor; + WidgetStateProperty? get todayBackgroundColor => dayBackgroundColor; @override BorderSide? get todayBorder => BorderSide(color: _colors.primary); @@ -1234,46 +1233,46 @@ class _DatePickerDefaultsM3 extends DatePickerThemeData { TextStyle? get yearStyle => _textTheme.bodyLarge; @override - MaterialStateProperty? get yearForegroundColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { + WidgetStateProperty? get yearForegroundColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { return _colors.onPrimary; - } else if (states.contains(MaterialState.disabled)) { + } else if (states.contains(WidgetState.disabled)) { return _colors.onSurfaceVariant.withOpacity(0.38); } return _colors.onSurfaceVariant; }); @override - MaterialStateProperty? get yearBackgroundColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { + WidgetStateProperty? get yearBackgroundColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { return _colors.primary; } return null; }); @override - MaterialStateProperty? get yearOverlayColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.selected)) { - if (states.contains(MaterialState.pressed)) { + WidgetStateProperty? get yearOverlayColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.selected)) { + if (states.contains(WidgetState.pressed)) { return _colors.onPrimary.withOpacity(0.1); } - if (states.contains(MaterialState.hovered)) { + if (states.contains(WidgetState.hovered)) { return _colors.onPrimary.withOpacity(0.08); } - if (states.contains(MaterialState.focused)) { + if (states.contains(WidgetState.focused)) { return _colors.onPrimary.withOpacity(0.1); } } else { - if (states.contains(MaterialState.pressed)) { + if (states.contains(WidgetState.pressed)) { return _colors.onSurfaceVariant.withOpacity(0.1); } - if (states.contains(MaterialState.hovered)) { + if (states.contains(WidgetState.hovered)) { return _colors.onSurfaceVariant.withOpacity(0.08); } - if (states.contains(MaterialState.focused)) { + if (states.contains(WidgetState.focused)) { return _colors.onSurfaceVariant.withOpacity(0.1); } } @@ -1290,15 +1289,15 @@ class _DatePickerDefaultsM3 extends DatePickerThemeData { Color? get rangeSelectionBackgroundColor => _colors.secondaryContainer; @override - MaterialStateProperty? get rangeSelectionOverlayColor => - MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.pressed)) { + WidgetStateProperty? get rangeSelectionOverlayColor => + WidgetStateProperty.resolveWith((Set states) { + if (states.contains(WidgetState.pressed)) { return _colors.onPrimaryContainer.withOpacity(0.1); } - if (states.contains(MaterialState.hovered)) { + if (states.contains(WidgetState.hovered)) { return _colors.onPrimaryContainer.withOpacity(0.08); } - if (states.contains(MaterialState.focused)) { + if (states.contains(WidgetState.focused)) { return _colors.onPrimaryContainer.withOpacity(0.1); } return null;