From 0fc6955177efbe20ad91396a9e53c4233d92edbe Mon Sep 17 00:00:00 2001 From: Taha Tesser Date: Tue, 26 Apr 2022 12:59:20 +0300 Subject: [PATCH 1/3] Migrate `toggleableActiveColor` Remove `toggleableActiveColor` from gallery set bulk apply and remove material.expect changes Update colors and revert a typo Update fix_data.yaml Update fix_data for existing themes .expect tests and minor fixes Fix conflicts fix analyzer issue Update fix_data and .expect test Update test Resolve conflict Update fix Resolve conflict --- .../flutter_gallery/lib/gallery/themes.dart | 2 - packages/flutter/lib/fix_data.yaml | 432 ++++++++++++++++++ .../flutter/lib/src/material/checkbox.dart | 8 +- .../lib/src/material/checkbox_list_tile.dart | 52 ++- packages/flutter/lib/src/material/radio.dart | 8 +- .../lib/src/material/radio_list_tile.dart | 66 +-- packages/flutter/lib/src/material/switch.dart | 10 +- .../lib/src/material/switch_list_tile.dart | 54 ++- .../flutter/lib/src/material/theme_data.dart | 42 +- .../material/checkbox_list_tile_test.dart | 20 +- .../flutter/test/material/checkbox_test.dart | 14 +- .../test/material/radio_list_tile_test.dart | 10 +- .../flutter/test/material/radio_test.dart | 8 +- .../test/material/switch_list_tile_test.dart | 10 +- .../flutter/test/material/switch_test.dart | 20 +- .../test/material/theme_data_test.dart | 10 +- packages/flutter/test_fixes/material.dart | 16 + .../flutter/test_fixes/material.dart.expect | 250 ++++++++++ 18 files changed, 897 insertions(+), 135 deletions(-) diff --git a/dev/integration_tests/flutter_gallery/lib/gallery/themes.dart b/dev/integration_tests/flutter_gallery/lib/gallery/themes.dart index 080d17155e127..f12de0cce1b0a 100644 --- a/dev/integration_tests/flutter_gallery/lib/gallery/themes.dart +++ b/dev/integration_tests/flutter_gallery/lib/gallery/themes.dart @@ -30,7 +30,6 @@ ThemeData _buildDarkTheme() { primaryColorDark: const Color(0xFF0050a0), primaryColorLight: secondaryColor, indicatorColor: Colors.white, - toggleableActiveColor: const Color(0xFF6997DF), canvasColor: const Color(0xFF202124), scaffoldBackgroundColor: const Color(0xFF202124), backgroundColor: const Color(0xFF202124), @@ -54,7 +53,6 @@ ThemeData _buildLightTheme() { colorScheme: colorScheme, primaryColor: primaryColor, indicatorColor: Colors.white, - toggleableActiveColor: const Color(0xFF1E88E5), splashColor: Colors.white24, splashFactory: InkRipple.splashFactory, canvasColor: Colors.white, diff --git a/packages/flutter/lib/fix_data.yaml b/packages/flutter/lib/fix_data.yaml index be4a44a03dbcc..8e1c5eec056fd 100644 --- a/packages/flutter/lib/fix_data.yaml +++ b/packages/flutter/lib/fix_data.yaml @@ -17,6 +17,438 @@ version: 1 transforms: + # Changes made in https://github.com/flutter/flutter/pull/97972/ + - title: "Migrate 'ThemeData.toggleableActiveColor' to individual themes" + date: 2022-05-18 + element: + uris: [ 'material.dart' ] + constructor: '' + inClass: 'ThemeData' + changes: + - kind: 'removeParameter' + name: 'toggleableActiveColor' + - kind: 'addParameter' + index: 96 + name: 'checkboxTheme' + style: optional_named + argumentValue: + expression: "CheckboxThemeData(\n + fillColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )," + requiredIf: "toggleableActiveColor != '' && checkboxTheme == ''" + - kind: 'addParameter' + index: 97 + name: 'checkboxTheme' + style: optional_named + argumentValue: + expression: "{% checkboxTheme %}.copyWith(\n + fillColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )," + requiredIf: "toggleableActiveColor != '' && checkboxTheme != ''" + - kind: 'addParameter' + index: 98 + name: 'radioTheme' + style: optional_named + argumentValue: + expression: "RadioThemeData(\n + fillColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )," + requiredIf: "toggleableActiveColor != '' && radioTheme == ''" + - kind: 'addParameter' + index: 99 + name: 'radioTheme' + style: optional_named + argumentValue: + expression: "{% radioTheme %}.copyWith(\n + fillColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )," + requiredIf: "toggleableActiveColor != '' && radioTheme != ''" + - kind: 'addParameter' + index: 100 + name: 'switchTheme' + style: optional_named + argumentValue: + expression: "SwitchThemeData(\n + thumbColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + trackColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )" + requiredIf: "toggleableActiveColor != '' && switchTheme == ''" + - kind: 'addParameter' + index: 101 + name: 'switchTheme' + style: optional_named + argumentValue: + expression: "{% switchTheme %}.copyWith(\n + thumbColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + trackColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )" + requiredIf: "toggleableActiveColor != '' && switchTheme != ''" + variables: + checkboxTheme: + kind: 'fragment' + value: 'arguments[checkboxTheme]' + radioTheme: + kind: 'fragment' + value: 'arguments[radioTheme]' + switchTheme: + kind: 'fragment' + value: 'arguments[switchTheme]' + toggleableActiveColor: + kind: 'fragment' + value: 'arguments[toggleableActiveColor]' + + # Changes made in https://github.com/flutter/flutter/pull/97972/ + - title: "Migrate 'ThemeData.raw.toggleableActiveColor' to individual themes" + date: 2022-05-18 + element: + uris: [ 'material.dart' ] + constructor: 'raw' + inClass: 'ThemeData' + changes: + - kind: 'removeParameter' + name: 'toggleableActiveColor' + - kind: 'addParameter' + index: 96 + name: 'checkboxTheme' + style: optional_named + argumentValue: + expression: "CheckboxThemeData(\n + fillColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )," + requiredIf: "toggleableActiveColor != '' && checkboxTheme == ''" + - kind: 'addParameter' + index: 97 + name: 'checkboxTheme' + style: optional_named + argumentValue: + expression: "{% checkboxTheme %}.copyWith(\n + fillColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )," + requiredIf: "toggleableActiveColor != '' && checkboxTheme != ''" + - kind: 'addParameter' + index: 98 + name: 'radioTheme' + style: optional_named + argumentValue: + expression: "RadioThemeData(\n + fillColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )," + requiredIf: "toggleableActiveColor != '' && radioTheme == ''" + - kind: 'addParameter' + index: 99 + name: 'radioTheme' + style: optional_named + argumentValue: + expression: "{% radioTheme %}.copyWith(\n + fillColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )," + requiredIf: "toggleableActiveColor != '' && radioTheme != ''" + - kind: 'addParameter' + index: 100 + name: 'switchTheme' + style: optional_named + argumentValue: + expression: "SwitchThemeData(\n + thumbColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + trackColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )" + requiredIf: "toggleableActiveColor != '' && switchTheme == ''" + - kind: 'addParameter' + index: 101 + name: 'switchTheme' + style: optional_named + argumentValue: + expression: "{% switchTheme %}.copyWith(\n + thumbColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + trackColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )" + requiredIf: "toggleableActiveColor != '' && switchTheme != ''" + variables: + checkboxTheme: + kind: 'fragment' + value: 'arguments[checkboxTheme]' + radioTheme: + kind: 'fragment' + value: 'arguments[radioTheme]' + switchTheme: + kind: 'fragment' + value: 'arguments[switchTheme]' + toggleableActiveColor: + kind: 'fragment' + value: 'arguments[toggleableActiveColor]' + + # Changes made in https://github.com/flutter/flutter/pull/97972/ + - title: "Migrate 'ThemeData.copyWith.toggleableActiveColor' to individual themes" + date: 2022-05-18 + element: + uris: [ 'material.dart' ] + method: 'copyWith' + inClass: 'ThemeData' + changes: + - kind: 'removeParameter' + name: 'toggleableActiveColor' + - kind: 'addParameter' + index: 96 + name: 'checkboxTheme' + style: optional_named + argumentValue: + expression: "CheckboxThemeData(\n + fillColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )," + requiredIf: "toggleableActiveColor != '' && checkboxTheme == ''" + - kind: 'addParameter' + index: 97 + name: 'checkboxTheme' + style: optional_named + argumentValue: + expression: "{% checkboxTheme %}.copyWith(\n + fillColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )," + requiredIf: "toggleableActiveColor != '' && checkboxTheme != ''" + - kind: 'addParameter' + index: 98 + name: 'radioTheme' + style: optional_named + argumentValue: + expression: "RadioThemeData(\n + fillColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )," + requiredIf: "toggleableActiveColor != '' && radioTheme == ''" + - kind: 'addParameter' + index: 99 + name: 'radioTheme' + style: optional_named + argumentValue: + expression: "{% radioTheme %}.copyWith(\n + fillColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )" + requiredIf: "toggleableActiveColor != '' && radioTheme != ''" + - kind: 'addParameter' + index: 100 + name: 'switchTheme' + style: optional_named + argumentValue: + expression: "SwitchThemeData(\n + thumbColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + trackColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )" + requiredIf: "toggleableActiveColor != '' && switchTheme == ''" + - kind: 'addParameter' + index: 101 + name: 'switchTheme' + style: optional_named + argumentValue: + expression: "{% switchTheme %}.copyWith(\n + thumbColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + trackColor: MaterialStateProperty.resolveWith((Set states) {\n + if (states.contains(MaterialState.disabled)) { + return null; + }\n + if (states.contains(MaterialState.selected)) { + return {% toggleableActiveColor %}; + }\n + return null;\n + }),\n + )," + requiredIf: "toggleableActiveColor != '' && switchTheme != ''" + variables: + checkboxTheme: + kind: 'fragment' + value: 'arguments[checkboxTheme]' + radioTheme: + kind: 'fragment' + value: 'arguments[radioTheme]' + switchTheme: + kind: 'fragment' + value: 'arguments[switchTheme]' + toggleableActiveColor: + kind: 'fragment' + value: 'arguments[toggleableActiveColor]' + # Changes made in https://github.com/flutter/flutter/pull/105291 - title: "Migrate 'ElevatedButton.styleFrom(primary)' to 'ElevatedButton.styleFrom(backgroundColor)'" date: 2022-05-27 diff --git a/packages/flutter/lib/src/material/checkbox.dart b/packages/flutter/lib/src/material/checkbox.dart index fe6d4f855aa44..a274c695caac5 100644 --- a/packages/flutter/lib/src/material/checkbox.dart +++ b/packages/flutter/lib/src/material/checkbox.dart @@ -147,7 +147,7 @@ class Checkbox extends StatefulWidget { /// The color to use when this checkbox is checked. /// - /// Defaults to [ThemeData.toggleableActiveColor]. + /// Defaults to [ColorScheme.secondary]. /// /// If [fillColor] returns a non-null color in the [MaterialState.selected] /// state, it will be used instead of this color. @@ -185,7 +185,7 @@ class Checkbox extends StatefulWidget { /// If null, then the value of [activeColor] is used in the selected /// state. If that is also null, the value of [CheckboxThemeData.fillColor] /// is used. If that is also null, then [ThemeData.disabledColor] is used in - /// the disabled state, [ThemeData.toggleableActiveColor] is used in the + /// the disabled state, [ColorScheme.secondary] is used in the /// selected state, and [ThemeData.unselectedWidgetColor] is used in the /// default state. final MaterialStateProperty? fillColor; @@ -272,7 +272,7 @@ class Checkbox extends StatefulWidget { /// [kRadialReactionAlpha], [focusColor] and [hoverColor] is used in the /// pressed, focused and hovered state. If that is also null, /// the value of [CheckboxThemeData.overlayColor] is used. If that is - /// also null, then the value of [ThemeData.toggleableActiveColor] with alpha + /// also null, then the value of [ColorScheme.secondary] with alpha /// [kRadialReactionAlpha], [ThemeData.focusColor] and [ThemeData.hoverColor] /// is used in the pressed, focused and hovered state. final MaterialStateProperty? overlayColor; @@ -385,7 +385,7 @@ class _CheckboxState extends State with TickerProviderStateMixin, Togg return themeData.disabledColor; } if (states.contains(MaterialState.selected)) { - return themeData.toggleableActiveColor; + return themeData.colorScheme.secondary; } return themeData.unselectedWidgetColor; }); diff --git a/packages/flutter/lib/src/material/checkbox_list_tile.dart b/packages/flutter/lib/src/material/checkbox_list_tile.dart index 93ba8d9abb428..94e7731fb2e63 100644 --- a/packages/flutter/lib/src/material/checkbox_list_tile.dart +++ b/packages/flutter/lib/src/material/checkbox_list_tile.dart @@ -5,8 +5,10 @@ import 'package:flutter/widgets.dart'; import 'checkbox.dart'; +import 'checkbox_theme.dart'; import 'list_tile.dart'; import 'list_tile_theme.dart'; +import 'material_state.dart'; import 'theme.dart'; import 'theme_data.dart'; @@ -29,7 +31,7 @@ import 'theme_data.dart'; /// /// The [selected] property on this widget is similar to the [ListTile.selected] /// property. This tile's [activeColor] is used for the selected item's text color, or -/// the theme's [ThemeData.toggleableActiveColor] if [activeColor] is null. +/// the theme's [CheckboxThemeData.overlayColor] if [activeColor] is null. /// /// This widget does not coordinate the [selected] state and the [value] state; to have the list tile /// appear selected when the checkbox is checked, pass the same value to both. @@ -372,28 +374,34 @@ class CheckboxListTile extends StatelessWidget { trailing = control; break; } + final ThemeData theme = Theme.of(context); + final CheckboxThemeData checkboxTheme = CheckboxTheme.of(context); + final Set states = { + if (selected) MaterialState.selected, + }; + final Color effectiveActiveColor = activeColor + ?? checkboxTheme.fillColor?.resolve(states) + ?? theme.colorScheme.secondary; return MergeSemantics( - child: ListTileTheme.merge( - selectedColor: activeColor ?? Theme.of(context).toggleableActiveColor, - child: ListTile( - leading: leading, - title: title, - subtitle: subtitle, - trailing: trailing, - isThreeLine: isThreeLine, - dense: dense, - enabled: enabled ?? onChanged != null, - onTap: onChanged != null ? _handleValueChange : null, - selected: selected, - autofocus: autofocus, - contentPadding: contentPadding, - shape: shape, - selectedTileColor: selectedTileColor, - tileColor: tileColor, - visualDensity: visualDensity, - focusNode: focusNode, - enableFeedback: enableFeedback, - ), + child: ListTile( + selectedColor: effectiveActiveColor, + leading: leading, + title: title, + subtitle: subtitle, + trailing: trailing, + isThreeLine: isThreeLine, + dense: dense, + enabled: enabled ?? onChanged != null, + onTap: onChanged != null ? _handleValueChange : null, + selected: selected, + autofocus: autofocus, + contentPadding: contentPadding, + shape: shape, + selectedTileColor: selectedTileColor, + tileColor: tileColor, + visualDensity: visualDensity, + focusNode: focusNode, + enableFeedback: enableFeedback, ), ); } diff --git a/packages/flutter/lib/src/material/radio.dart b/packages/flutter/lib/src/material/radio.dart index 7daff69b5edac..128688daeec5f 100644 --- a/packages/flutter/lib/src/material/radio.dart +++ b/packages/flutter/lib/src/material/radio.dart @@ -175,7 +175,7 @@ class Radio extends StatefulWidget { /// The color to use when this radio button is selected. /// - /// Defaults to [ThemeData.toggleableActiveColor]. + /// Defaults to [ColorScheme.secondary]. /// /// If [fillColor] returns a non-null color in the [MaterialState.selected] /// state, it will be used instead of this color. @@ -214,7 +214,7 @@ class Radio extends StatefulWidget { /// If null, then the value of [activeColor] is used in the selected state. If /// that is also null, then the value of [RadioThemeData.fillColor] is used. /// If that is also null, then [ThemeData.disabledColor] is used in - /// the disabled state, [ThemeData.toggleableActiveColor] is used in the + /// the disabled state, [ColorScheme.secondary] is used in the /// selected state, and [ThemeData.unselectedWidgetColor] is used in the /// default state. final MaterialStateProperty? fillColor; @@ -281,7 +281,7 @@ class Radio extends StatefulWidget { /// [kRadialReactionAlpha], [focusColor] and [hoverColor] is used in the /// pressed, focused and hovered state. If that is also null, /// the value of [RadioThemeData.overlayColor] is used. If that is also null, - /// then the value of [ThemeData.toggleableActiveColor] with alpha + /// then the value of [ColorScheme.secondary] with alpha /// [kRadialReactionAlpha], [ThemeData.focusColor] and [ThemeData.hoverColor] /// is used in the pressed, focused and hovered state. final MaterialStateProperty? overlayColor; @@ -361,7 +361,7 @@ class _RadioState extends State> with TickerProviderStateMixin, Togg return themeData.disabledColor; } if (states.contains(MaterialState.selected)) { - return themeData.toggleableActiveColor; + return themeData.colorScheme.secondary; } return themeData.unselectedWidgetColor; }); diff --git a/packages/flutter/lib/src/material/radio_list_tile.dart b/packages/flutter/lib/src/material/radio_list_tile.dart index ff180812e9275..6c64e1ba52e27 100644 --- a/packages/flutter/lib/src/material/radio_list_tile.dart +++ b/packages/flutter/lib/src/material/radio_list_tile.dart @@ -6,7 +6,9 @@ import 'package:flutter/widgets.dart'; import 'list_tile.dart'; import 'list_tile_theme.dart'; +import 'material_state.dart'; import 'radio.dart'; +import 'radio_theme.dart'; import 'theme.dart'; import 'theme_data.dart'; @@ -346,36 +348,42 @@ class RadioListTile extends StatelessWidget { trailing = control; break; } + final ThemeData theme = Theme.of(context); + final RadioThemeData radioThemeData = RadioTheme.of(context); + final Set states = { + if (selected) MaterialState.selected, + }; + final Color effectiveActiveColor = activeColor + ?? radioThemeData.fillColor?.resolve(states) + ?? theme.colorScheme.secondary; return MergeSemantics( - child: ListTileTheme.merge( - selectedColor: activeColor ?? Theme.of(context).toggleableActiveColor, - child: ListTile( - leading: leading, - title: title, - subtitle: subtitle, - trailing: trailing, - isThreeLine: isThreeLine, - dense: dense, - enabled: onChanged != null, - shape: shape, - tileColor: tileColor, - selectedTileColor: selectedTileColor, - onTap: onChanged != null ? () { - if (toggleable && checked) { - onChanged!(null); - return; - } - if (!checked) { - onChanged!(value); - } - } : null, - selected: selected, - autofocus: autofocus, - contentPadding: contentPadding, - visualDensity: visualDensity, - focusNode: focusNode, - enableFeedback: enableFeedback, - ), + child: ListTile( + selectedColor: effectiveActiveColor, + leading: leading, + title: title, + subtitle: subtitle, + trailing: trailing, + isThreeLine: isThreeLine, + dense: dense, + enabled: onChanged != null, + shape: shape, + tileColor: tileColor, + selectedTileColor: selectedTileColor, + onTap: onChanged != null ? () { + if (toggleable && checked) { + onChanged!(null); + return; + } + if (!checked) { + onChanged!(value); + } + } : null, + selected: selected, + autofocus: autofocus, + contentPadding: contentPadding, + visualDensity: visualDensity, + focusNode: focusNode, + enableFeedback: enableFeedback, ), ); } diff --git a/packages/flutter/lib/src/material/switch.dart b/packages/flutter/lib/src/material/switch.dart index 0c0ca3e3bd25a..7732a30e337ff 100644 --- a/packages/flutter/lib/src/material/switch.dart +++ b/packages/flutter/lib/src/material/switch.dart @@ -182,7 +182,7 @@ class Switch extends StatelessWidget { /// The color to use when this switch is on. /// - /// Defaults to [ThemeData.toggleableActiveColor]. + /// Defaults to [ColorScheme.secondary]. /// /// If [thumbColor] returns a non-null color in the [MaterialState.selected] /// state, it will be used instead of this color. @@ -190,7 +190,7 @@ class Switch extends StatelessWidget { /// The color to use on the track when this switch is on. /// - /// Defaults to [ThemeData.toggleableActiveColor] with the opacity set at 50%. + /// Defaults to [ColorScheme.secondary] with the opacity set at 50%. /// /// Ignored if this switch is created with [Switch.adaptive]. /// @@ -273,7 +273,7 @@ class Switch extends StatelessWidget { /// | State | Light theme | Dark theme | /// |----------|-----------------------------------|-----------------------------------| /// | Default | `Colors.grey.shade50` | `Colors.grey.shade400` | - /// | Selected | [ThemeData.toggleableActiveColor] | [ThemeData.toggleableActiveColor] | + /// | Selected | [ColorScheme.secondary] | [ColorScheme.secondary] | /// | Disabled | `Colors.grey.shade400` | `Colors.grey.shade800` | final MaterialStateProperty? thumbColor; @@ -393,7 +393,7 @@ class Switch extends StatelessWidget { /// [kRadialReactionAlpha], [focusColor] and [hoverColor] is used in the /// pressed, focused and hovered state. If that is also null, /// the value of [SwitchThemeData.overlayColor] is used. If that is - /// also null, then the value of [ThemeData.toggleableActiveColor] with alpha + /// also null, then the value of [ColorScheme.secondary] with alpha /// [kRadialReactionAlpha], [ThemeData.focusColor] and [ThemeData.hoverColor] /// is used in the pressed, focused and hovered state. final MaterialStateProperty? overlayColor; @@ -614,7 +614,7 @@ class _MaterialSwitchState extends State<_MaterialSwitch> with TickerProviderSta return isDark ? Colors.grey.shade800 : Colors.grey.shade400; } if (states.contains(MaterialState.selected)) { - return theme.toggleableActiveColor; + return theme.colorScheme.secondary; } return isDark ? Colors.grey.shade400 : Colors.grey.shade50; }); diff --git a/packages/flutter/lib/src/material/switch_list_tile.dart b/packages/flutter/lib/src/material/switch_list_tile.dart index 8180dd6f4cef3..3d9a94e477856 100644 --- a/packages/flutter/lib/src/material/switch_list_tile.dart +++ b/packages/flutter/lib/src/material/switch_list_tile.dart @@ -6,7 +6,9 @@ import 'package:flutter/widgets.dart'; import 'list_tile.dart'; import 'list_tile_theme.dart'; +import 'material_state.dart'; import 'switch.dart'; +import 'switch_theme.dart'; import 'theme.dart'; import 'theme_data.dart'; @@ -37,7 +39,7 @@ enum _SwitchListTileType { material, adaptive } /// /// The [selected] property on this widget is similar to the [ListTile.selected] /// property. This tile's [activeColor] is used for the selected item's text color, or -/// the theme's [ThemeData.toggleableActiveColor] if [activeColor] is null. +/// the theme's [SwitchThemeData.overlayColor] if [activeColor] is null. /// /// This widget does not coordinate the [selected] state and the /// [value]; to have the list tile appear selected when the @@ -423,29 +425,35 @@ class SwitchListTile extends StatelessWidget { break; } + final ThemeData theme = Theme.of(context); + final SwitchThemeData switchTheme = SwitchTheme.of(context); + final Set states = { + if (selected) MaterialState.selected, + }; + final Color effectiveActiveColor = activeColor + ?? switchTheme.thumbColor?.resolve(states) + ?? theme.colorScheme.secondary; return MergeSemantics( - child: ListTileTheme.merge( - selectedColor: activeColor ?? Theme.of(context).toggleableActiveColor, - child: ListTile( - leading: leading, - title: title, - subtitle: subtitle, - trailing: trailing, - isThreeLine: isThreeLine, - dense: dense, - contentPadding: contentPadding, - enabled: onChanged != null, - onTap: onChanged != null ? () { onChanged!(!value); } : null, - selected: selected, - selectedTileColor: selectedTileColor, - autofocus: autofocus, - shape: shape, - tileColor: tileColor, - visualDensity: visualDensity, - focusNode: focusNode, - enableFeedback: enableFeedback, - hoverColor: hoverColor, - ), + child: ListTile( + selectedColor: effectiveActiveColor, + leading: leading, + title: title, + subtitle: subtitle, + trailing: trailing, + isThreeLine: isThreeLine, + dense: dense, + contentPadding: contentPadding, + enabled: onChanged != null, + onTap: onChanged != null ? () { onChanged!(!value); } : null, + selected: selected, + selectedTileColor: selectedTileColor, + autofocus: autofocus, + shape: shape, + tileColor: tileColor, + visualDensity: visualDensity, + focusNode: focusNode, + enableFeedback: enableFeedback, + hoverColor: hoverColor, ), ); } diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart index 1e2f6e3ccdd38..29ae6d5e5dcef 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -313,7 +313,6 @@ class ThemeData with Diagnosticable { Color? selectedRowColor, Color? shadowColor, Color? splashColor, - Color? toggleableActiveColor, Color? unselectedWidgetColor, // TYPOGRAPHY & ICONOGRAPHY String? fontFamily, @@ -405,6 +404,13 @@ class ThemeData with Diagnosticable { 'This feature was deprecated after v2.13.0-0.0.pre.' ) AndroidOverscrollIndicator? androidOverscrollIndicator, + @Deprecated( + 'No longer used by the framework, please remove any reference to it. ' + 'For more information, consult the migration guide at ' + 'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. ' + 'This feature was deprecated after v2.13.0-0.4.pre.', + ) + Color? toggleableActiveColor, }) { // GENERAL CONFIGURATION cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault(); @@ -614,7 +620,6 @@ class ThemeData with Diagnosticable { selectedRowColor: selectedRowColor, shadowColor: shadowColor, splashColor: splashColor, - toggleableActiveColor: toggleableActiveColor, unselectedWidgetColor: unselectedWidgetColor, // TYPOGRAPHY & ICONOGRAPHY iconTheme: iconTheme, @@ -665,6 +670,7 @@ class ThemeData with Diagnosticable { fixTextFieldOutlineLabel: fixTextFieldOutlineLabel, primaryColorBrightness: primaryColorBrightness, androidOverscrollIndicator: androidOverscrollIndicator, + toggleableActiveColor: toggleableActiveColor, ); } @@ -719,7 +725,6 @@ class ThemeData with Diagnosticable { required this.selectedRowColor, required this.shadowColor, required this.splashColor, - required this.toggleableActiveColor, required this.unselectedWidgetColor, // TYPOGRAPHY & ICONOGRAPHY required this.iconTheme, @@ -810,6 +815,13 @@ class ThemeData with Diagnosticable { 'This feature was deprecated after v2.13.0-0.0.pre.' ) this.androidOverscrollIndicator, + @Deprecated( + 'No longer used by the framework, please remove any reference to it. ' + 'For more information, consult the migration guide at ' + 'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. ' + 'This feature was deprecated after v2.13.0-0.4.pre.', + ) + Color? toggleableActiveColor, }) : // DEPRECATED (newest deprecations at the bottom) // should not be `required`, use getter pattern to avoid breakages. _accentColor = accentColor, @@ -819,6 +831,7 @@ class ThemeData with Diagnosticable { _buttonColor = buttonColor, _fixTextFieldOutlineLabel = fixTextFieldOutlineLabel, _primaryColorBrightness = primaryColorBrightness, + _toggleableActiveColor = toggleableActiveColor, // GENERAL CONFIGURATION assert(applyElevationOverlayColor != null), assert(extensions != null), @@ -1341,7 +1354,8 @@ class ThemeData with Diagnosticable { /// The color used to highlight the active states of toggleable widgets like /// [Switch], [Radio], and [Checkbox]. - final Color toggleableActiveColor; + Color get toggleableActiveColor => _toggleableActiveColor!; + final Color? _toggleableActiveColor; /// The color used for widgets in their inactive (but enabled) /// state. For example, an unchecked checkbox. See also [disabledColor]. @@ -1673,7 +1687,6 @@ class ThemeData with Diagnosticable { Color? selectedRowColor, Color? shadowColor, Color? splashColor, - Color? toggleableActiveColor, Color? unselectedWidgetColor, // TYPOGRAPHY & ICONOGRAPHY IconThemeData? iconTheme, @@ -1764,6 +1777,13 @@ class ThemeData with Diagnosticable { 'This feature was deprecated after v2.13.0-0.0.pre.' ) AndroidOverscrollIndicator? androidOverscrollIndicator, + @Deprecated( + 'No longer used by the framework, please remove any reference to it. ' + 'For more information, consult the migration guide at ' + 'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. ' + 'This feature was deprecated after v2.13.0-0.4.pre.', + ) + Color? toggleableActiveColor, }) { cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault(); return ThemeData.raw( @@ -1807,7 +1827,6 @@ class ThemeData with Diagnosticable { selectedRowColor: selectedRowColor ?? this.selectedRowColor, shadowColor: shadowColor ?? this.shadowColor, splashColor: splashColor ?? this.splashColor, - toggleableActiveColor: toggleableActiveColor ?? this.toggleableActiveColor, unselectedWidgetColor: unselectedWidgetColor ?? this.unselectedWidgetColor, // TYPOGRAPHY & ICONOGRAPHY iconTheme: iconTheme ?? this.iconTheme, @@ -1858,6 +1877,7 @@ class ThemeData with Diagnosticable { fixTextFieldOutlineLabel: fixTextFieldOutlineLabel ?? this.fixTextFieldOutlineLabel, primaryColorBrightness: primaryColorBrightness ?? this.primaryColorBrightness, androidOverscrollIndicator: androidOverscrollIndicator ?? this.androidOverscrollIndicator, + toggleableActiveColor: toggleableActiveColor ?? this.toggleableActiveColor, ); } @@ -2005,7 +2025,6 @@ class ThemeData with Diagnosticable { selectedRowColor: Color.lerp(a.selectedRowColor, b.selectedRowColor, t)!, shadowColor: Color.lerp(a.shadowColor, b.shadowColor, t)!, splashColor: Color.lerp(a.splashColor, b.splashColor, t)!, - toggleableActiveColor: Color.lerp(a.toggleableActiveColor, b.toggleableActiveColor, t)!, unselectedWidgetColor: Color.lerp(a.unselectedWidgetColor, b.unselectedWidgetColor, t)!, // TYPOGRAPHY & ICONOGRAPHY iconTheme: IconThemeData.lerp(a.iconTheme, b.iconTheme, t), @@ -2056,6 +2075,7 @@ class ThemeData with Diagnosticable { fixTextFieldOutlineLabel: t < 0.5 ? a.fixTextFieldOutlineLabel : b.fixTextFieldOutlineLabel, primaryColorBrightness: t < 0.5 ? a.primaryColorBrightness : b.primaryColorBrightness, androidOverscrollIndicator:t < 0.5 ? a.androidOverscrollIndicator : b.androidOverscrollIndicator, + toggleableActiveColor: Color.lerp(a.toggleableActiveColor, b.toggleableActiveColor, t), ); } @@ -2105,7 +2125,6 @@ class ThemeData with Diagnosticable { other.selectedRowColor == selectedRowColor && other.shadowColor == shadowColor && other.splashColor == splashColor && - other.toggleableActiveColor == toggleableActiveColor && other.unselectedWidgetColor == unselectedWidgetColor && // TYPOGRAPHY & ICONOGRAPHY other.iconTheme == iconTheme && @@ -2155,7 +2174,8 @@ class ThemeData with Diagnosticable { other.buttonColor == buttonColor && other.fixTextFieldOutlineLabel == fixTextFieldOutlineLabel && other.primaryColorBrightness == primaryColorBrightness && - other.androidOverscrollIndicator == androidOverscrollIndicator; + other.androidOverscrollIndicator == androidOverscrollIndicator && + other.toggleableActiveColor == toggleableActiveColor; } @override @@ -2202,7 +2222,6 @@ class ThemeData with Diagnosticable { selectedRowColor, shadowColor, splashColor, - toggleableActiveColor, unselectedWidgetColor, // TYPOGRAPHY & ICONOGRAPHY iconTheme, @@ -2253,6 +2272,7 @@ class ThemeData with Diagnosticable { fixTextFieldOutlineLabel, primaryColorBrightness, androidOverscrollIndicator, + toggleableActiveColor, ]; return Object.hashAll(values); } @@ -2301,7 +2321,6 @@ class ThemeData with Diagnosticable { properties.add(ColorProperty('selectedRowColor', selectedRowColor, defaultValue: defaultData.selectedRowColor, level: DiagnosticLevel.debug)); properties.add(ColorProperty('shadowColor', shadowColor, defaultValue: defaultData.shadowColor, level: DiagnosticLevel.debug)); properties.add(ColorProperty('splashColor', splashColor, defaultValue: defaultData.splashColor, level: DiagnosticLevel.debug)); - properties.add(ColorProperty('toggleableActiveColor', toggleableActiveColor, defaultValue: defaultData.toggleableActiveColor, level: DiagnosticLevel.debug)); properties.add(ColorProperty('unselectedWidgetColor', unselectedWidgetColor, defaultValue: defaultData.unselectedWidgetColor, level: DiagnosticLevel.debug)); // TYPOGRAPHY & ICONOGRAPHY properties.add(DiagnosticsProperty('iconTheme', iconTheme, level: DiagnosticLevel.debug)); @@ -2352,6 +2371,7 @@ class ThemeData with Diagnosticable { properties.add(DiagnosticsProperty('fixTextFieldOutlineLabel', fixTextFieldOutlineLabel, level: DiagnosticLevel.debug)); properties.add(EnumProperty('primaryColorBrightness', primaryColorBrightness, defaultValue: defaultData.primaryColorBrightness, level: DiagnosticLevel.debug)); properties.add(EnumProperty('androidOverscrollIndicator', androidOverscrollIndicator, defaultValue: null, level: DiagnosticLevel.debug)); + properties.add(ColorProperty('toggleableActiveColor', toggleableActiveColor, defaultValue: defaultData.toggleableActiveColor, level: DiagnosticLevel.debug)); } } diff --git a/packages/flutter/test/material/checkbox_list_tile_test.dart b/packages/flutter/test/material/checkbox_list_tile_test.dart index ee161a06fdaeb..90b4213d87e7d 100644 --- a/packages/flutter/test/material/checkbox_list_tile_test.dart +++ b/packages/flutter/test/material/checkbox_list_tile_test.dart @@ -36,7 +36,7 @@ void main() { }); testWidgets('CheckboxListTile checkColor test', (WidgetTester tester) async { - const Color checkBoxBorderColor = Color(0xff1e88e5); + const Color checkBoxBorderColor = Color(0xff2196f3); Color checkBoxCheckColor = const Color(0xffFFFFFF); Widget buildFrame(Color? color) { @@ -68,7 +68,13 @@ void main() { Widget buildFrame(Color? themeColor, Color? activeColor) { return wrap( child: Theme( - data: ThemeData(toggleableActiveColor: themeColor), + data: ThemeData( + checkboxTheme: CheckboxThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + return states.contains(MaterialState.selected) ? themeColor : null; + }), + ), + ), child: CheckboxListTile( value: true, activeColor: activeColor, @@ -291,10 +297,14 @@ void main() { const Color activeColor = Color(0xff00ff00); - Widget buildFrame({ Color? activeColor, Color? toggleableActiveColor }) { + Widget buildFrame({ Color? activeColor, Color? fillColor }) { return MaterialApp( theme: ThemeData.light().copyWith( - toggleableActiveColor: toggleableActiveColor, + checkboxTheme: CheckboxThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + return states.contains(MaterialState.selected) ? fillColor : null; + }), + ), ), home: Scaffold( body: Center( @@ -314,7 +324,7 @@ void main() { return tester.renderObject(find.text(text)).text.style?.color; } - await tester.pumpWidget(buildFrame(toggleableActiveColor: activeColor)); + await tester.pumpWidget(buildFrame(fillColor: activeColor)); expect(textColor('title'), activeColor); await tester.pumpWidget(buildFrame(activeColor: activeColor)); diff --git a/packages/flutter/test/material/checkbox_test.dart b/packages/flutter/test/material/checkbox_test.dart index 186c04ef088fd..06c163ab72d77 100644 --- a/packages/flutter/test/material/checkbox_test.dart +++ b/packages/flutter/test/material/checkbox_test.dart @@ -353,7 +353,7 @@ void main() { }); testWidgets('CheckBox color rendering', (WidgetTester tester) async { - const Color borderColor = Color(0xff1e88e5); + const Color borderColor = Color(0xff2196f3); Color checkColor = const Color(0xffFFFFFF); Color activeColor; @@ -391,7 +391,11 @@ void main() { activeColor = const Color(0xFF00FF00); - await tester.pumpWidget(buildFrame(themeData: ThemeData(toggleableActiveColor: activeColor))); + await tester.pumpWidget(buildFrame( + themeData: ThemeData( + colorScheme: const ColorScheme.light() + .copyWith(secondary: activeColor))), + ); await tester.pumpAndSettle(); expect(getCheckboxRenderer(), paints..path(color: activeColor)); // paints's color is 0xFF00FF00 (theme) @@ -435,7 +439,7 @@ void main() { Material.of(tester.element(find.byType(Checkbox))), paints ..circle(color: Colors.orange[500]) - ..path(color: const Color(0xff1e88e5)) + ..path(color: const Color(0xff2196f3)) ..path(color: Colors.white), ); @@ -526,7 +530,7 @@ void main() { expect( Material.of(tester.element(find.byType(Checkbox))), paints - ..path(color: const Color(0xff1e88e5)) + ..path(color: const Color(0xff2196f3)) ..path(color: const Color(0xffffffff),style: PaintingStyle.stroke, strokeWidth: 2.0), ); @@ -539,7 +543,7 @@ void main() { expect( Material.of(tester.element(find.byType(Checkbox))), paints - ..path(color: const Color(0xff1e88e5)) + ..path(color: const Color(0xff2196f3)) ..path(color: const Color(0xffffffff), style: PaintingStyle.stroke, strokeWidth: 2.0), ); diff --git a/packages/flutter/test/material/radio_list_tile_test.dart b/packages/flutter/test/material/radio_list_tile_test.dart index aed947486842d..7e720d5981e6f 100644 --- a/packages/flutter/test/material/radio_list_tile_test.dart +++ b/packages/flutter/test/material/radio_list_tile_test.dart @@ -710,10 +710,14 @@ void main() { const Color activeColor = Color(0xff00ff00); - Widget buildFrame({ Color? activeColor, Color? toggleableActiveColor }) { + Widget buildFrame({ Color? activeColor, Color? fillColor }) { return MaterialApp( theme: ThemeData.light().copyWith( - toggleableActiveColor: toggleableActiveColor, + radioTheme: RadioThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + return states.contains(MaterialState.selected) ? fillColor : null; + }), + ), ), home: Scaffold( body: Center( @@ -734,7 +738,7 @@ void main() { return tester.renderObject(find.text(text)).text.style?.color; } - await tester.pumpWidget(buildFrame(toggleableActiveColor: activeColor)); + await tester.pumpWidget(buildFrame(fillColor: activeColor)); expect(textColor('title'), activeColor); await tester.pumpWidget(buildFrame(activeColor: activeColor)); diff --git a/packages/flutter/test/material/radio_test.dart b/packages/flutter/test/material/radio_test.dart index ce8aa1f8f223e..33105435cdae8 100644 --- a/packages/flutter/test/material/radio_test.dart +++ b/packages/flutter/test/material/radio_test.dart @@ -441,8 +441,8 @@ void main() { rect: const Rect.fromLTRB(350.0, 250.0, 450.0, 350.0), ) ..circle(color: Colors.orange[500]) - ..circle(color: const Color(0xff1e88e5)) - ..circle(color: const Color(0xff1e88e5)), + ..circle(color: const Color(0xff2196f3)) + ..circle(color: const Color(0xff2196f3)), ); // Check when the radio isn't selected. @@ -519,8 +519,8 @@ void main() { color: const Color(0xffffffff), rect: const Rect.fromLTRB(350.0, 250.0, 450.0, 350.0), ) - ..circle(color: const Color(0xff1e88e5)) - ..circle(color: const Color(0xff1e88e5)), + ..circle(color: const Color(0xff2196f3)) + ..circle(color: const Color(0xff2196f3)), ); // Start hovering diff --git a/packages/flutter/test/material/switch_list_tile_test.dart b/packages/flutter/test/material/switch_list_tile_test.dart index df766f40ce417..2529409085921 100644 --- a/packages/flutter/test/material/switch_list_tile_test.dart +++ b/packages/flutter/test/material/switch_list_tile_test.dart @@ -400,10 +400,14 @@ void main() { const Color activeColor = Color(0xff00ff00); - Widget buildFrame({ Color? activeColor, Color? toggleableActiveColor }) { + Widget buildFrame({ Color? activeColor, Color? thumbColor }) { return MaterialApp( theme: ThemeData.light().copyWith( - toggleableActiveColor: toggleableActiveColor, + switchTheme: SwitchThemeData( + thumbColor: MaterialStateProperty.resolveWith((Set states) { + return states.contains(MaterialState.selected) ? thumbColor : null; + }), + ), ), home: Scaffold( body: Center( @@ -423,7 +427,7 @@ void main() { return tester.renderObject(find.text(text)).text.style?.color; } - await tester.pumpWidget(buildFrame(toggleableActiveColor: activeColor)); + await tester.pumpWidget(buildFrame(activeColor: activeColor)); expect(textColor('title'), activeColor); await tester.pumpWidget(buildFrame(activeColor: activeColor)); diff --git a/packages/flutter/test/material/switch_test.dart b/packages/flutter/test/material/switch_test.dart index d4595a6ba323b..9eac14b038bca 100644 --- a/packages/flutter/test/material/switch_test.dart +++ b/packages/flutter/test/material/switch_test.dart @@ -373,13 +373,13 @@ void main() { Material.of(tester.element(find.byType(Switch))), paints ..rrect( - color: Colors.blue[600]!.withAlpha(0x80), + color: const Color(0x802196f3), rrect: RRect.fromLTRBR(13.0, 17.0, 46.0, 31.0, const Radius.circular(7.0)), ) ..circle(color: const Color(0x33000000)) ..circle(color: const Color(0x24000000)) ..circle(color: const Color(0x1f000000)) - ..circle(color: Colors.blue[600]), + ..circle(color: const Color(0xff2196f3)), reason: 'Active enabled switch should match these colors', ); }); @@ -806,14 +806,14 @@ void main() { Material.of(tester.element(find.byType(Switch))), paints ..rrect( - color: const Color(0x801e88e5), + color: const Color(0x802196f3), rrect: RRect.fromLTRBR(13.0, 17.0, 46.0, 31.0, const Radius.circular(7.0)), ) ..circle(color: Colors.orange[500]) ..circle(color: const Color(0x33000000)) ..circle(color: const Color(0x24000000)) ..circle(color: const Color(0x1f000000)) - ..circle(color: const Color(0xff1e88e5)), + ..circle(color: const Color(0xff2196f3)), ); // Check the false value. @@ -910,13 +910,13 @@ void main() { Material.of(tester.element(find.byType(Switch))), paints ..rrect( - color: const Color(0x801e88e5), + color: const Color(0x802196f3), rrect: RRect.fromLTRBR(13.0, 17.0, 46.0, 31.0, const Radius.circular(7.0)), ) ..circle(color: const Color(0x33000000)) ..circle(color: const Color(0x24000000)) ..circle(color: const Color(0x1f000000)) - ..circle(color: const Color(0xff1e88e5)), + ..circle(color: const Color(0xff2196f3)), ); // Start hovering @@ -930,14 +930,14 @@ void main() { Material.of(tester.element(find.byType(Switch))), paints ..rrect( - color: const Color(0x801e88e5), + color: const Color(0x802196f3), rrect: RRect.fromLTRBR(13.0, 17.0, 46.0, 31.0, const Radius.circular(7.0)), ) ..circle(color: Colors.orange[500]) ..circle(color: const Color(0x33000000)) ..circle(color: const Color(0x24000000)) ..circle(color: const Color(0x1f000000)) - ..circle(color: const Color(0xff1e88e5)), + ..circle(color: const Color(0xff2196f3)), ); // Check what happens when disabled. @@ -1297,7 +1297,7 @@ void main() { Material.of(tester.element(find.byType(Switch))), paints ..rrect( - color: const Color(0x801e88e5), + color: const Color(0x802196f3), rrect: RRect.fromLTRBR(13.0, 17.0, 46.0, 31.0, const Radius.circular(7.0)), ) ..circle(color: const Color(0x1f000000)) @@ -1318,7 +1318,7 @@ void main() { Material.of(tester.element(find.byType(Switch))), paints ..rrect( - color: const Color(0x801e88e5), + color: const Color(0x802196f3), rrect: RRect.fromLTRBR(13.0, 17.0, 46.0, 31.0, const Radius.circular(7.0)), ) ..circle(color: const Color(0x1f000000)) diff --git a/packages/flutter/test/material/theme_data_test.dart b/packages/flutter/test/material/theme_data_test.dart index 9afd71bc99dc1..1162969577e00 100644 --- a/packages/flutter/test/material/theme_data_test.dart +++ b/packages/flutter/test/material/theme_data_test.dart @@ -672,7 +672,6 @@ void main() { selectedRowColor: Colors.black, shadowColor: Colors.black, splashColor: Colors.black, - toggleableActiveColor: Colors.black, unselectedWidgetColor: Colors.black, // TYPOGRAPHY & ICONOGRAPHY iconTheme: ThemeData.dark().iconTheme, @@ -723,6 +722,7 @@ void main() { fixTextFieldOutlineLabel: false, primaryColorBrightness: Brightness.dark, androidOverscrollIndicator: AndroidOverscrollIndicator.glow, + toggleableActiveColor: Colors.black, ); final SliderThemeData otherSliderTheme = SliderThemeData.fromPrimaryColors( @@ -782,7 +782,6 @@ void main() { selectedRowColor: Colors.white, shadowColor: Colors.white, splashColor: Colors.white, - toggleableActiveColor: Colors.white, unselectedWidgetColor: Colors.white, // TYPOGRAPHY & ICONOGRAPHY @@ -836,6 +835,7 @@ void main() { fixTextFieldOutlineLabel: true, primaryColorBrightness: Brightness.light, androidOverscrollIndicator: AndroidOverscrollIndicator.stretch, + toggleableActiveColor: Colors.white, ); final ThemeData themeDataCopy = theme.copyWith( @@ -880,7 +880,6 @@ void main() { selectedRowColor: otherTheme.selectedRowColor, shadowColor: otherTheme.shadowColor, splashColor: otherTheme.splashColor, - toggleableActiveColor: otherTheme.toggleableActiveColor, unselectedWidgetColor: otherTheme.unselectedWidgetColor, // TYPOGRAPHY & ICONOGRAPHY @@ -934,6 +933,7 @@ void main() { fixTextFieldOutlineLabel: otherTheme.fixTextFieldOutlineLabel, primaryColorBrightness: otherTheme.primaryColorBrightness, androidOverscrollIndicator: otherTheme.androidOverscrollIndicator, + toggleableActiveColor: otherTheme.toggleableActiveColor, ); // For the sanity of the reader, make sure these properties are in the same @@ -977,7 +977,6 @@ void main() { expect(themeDataCopy.selectedRowColor, equals(otherTheme.selectedRowColor)); expect(themeDataCopy.shadowColor, equals(otherTheme.shadowColor)); expect(themeDataCopy.splashColor, equals(otherTheme.splashColor)); - expect(themeDataCopy.toggleableActiveColor, equals(otherTheme.toggleableActiveColor)); expect(themeDataCopy.unselectedWidgetColor, equals(otherTheme.unselectedWidgetColor)); // TYPOGRAPHY & ICONOGRAPHY @@ -1036,6 +1035,7 @@ void main() { expect(themeDataCopy.fixTextFieldOutlineLabel, equals(otherTheme.fixTextFieldOutlineLabel)); expect(themeDataCopy.primaryColorBrightness, equals(otherTheme.primaryColorBrightness)); expect(themeDataCopy.androidOverscrollIndicator, equals(otherTheme.androidOverscrollIndicator)); + expect(themeDataCopy.toggleableActiveColor, equals(otherTheme.toggleableActiveColor)); }); testWidgets('ThemeData.toString has less than 200 characters output', (WidgetTester tester) async { @@ -1115,7 +1115,6 @@ void main() { 'indicatorColor', 'hintColor', 'errorColor', - 'toggleableActiveColor', // TYPOGRAPHY & ICONOGRAPHY 'typography', 'textTheme', @@ -1165,6 +1164,7 @@ void main() { 'fixTextFieldOutlineLabel', 'primaryColorBrightness', 'androidOverscrollIndicator', + 'toggleableActiveColor', }; final DiagnosticPropertiesBuilder properties = DiagnosticPropertiesBuilder(); diff --git a/packages/flutter/test_fixes/material.dart b/packages/flutter/test_fixes/material.dart index f60f8b1693d28..7811e86b205c7 100644 --- a/packages/flutter/test_fixes/material.dart +++ b/packages/flutter/test_fixes/material.dart @@ -569,4 +569,20 @@ void main() { primary: Colors.blue, onSurface: Colors.grey, ); + + // Changes made in https://github.com/flutter/flutter/pull/97972 + ThemeData themeData = ThemeData(); + themeData = ThemeData(toggleableActiveColor: Colors.black); + themeData = ThemeData( + toggleableActiveColor: Colors.black, + ); + themeData = ThemeData.raw(toggleableActiveColor: Colors.black); + themeData = ThemeData.raw( + toggleableActiveColor: Colors.black, + ); + themeData = themeData.copyWith(toggleableActiveColor: Colors.black); + themeData = themeData.copyWith( + toggleableActiveColor: Colors.black, + ); + themeData.toggleableActiveColor; // Removing field reference not supported. } diff --git a/packages/flutter/test_fixes/material.dart.expect b/packages/flutter/test_fixes/material.dart.expect index 985c843b5d011..4706bc8d03c9f 100644 --- a/packages/flutter/test_fixes/material.dart.expect +++ b/packages/flutter/test_fixes/material.dart.expect @@ -538,4 +538,254 @@ void main() { ButtonStyle textButtonStyle = TextButton.styleFrom( foregroundColor: Colors.blue, disabledForegroundColor: Colors.grey.withOpacity(0.38), ); + + // Changes made in https://github.com/flutter/flutter/pull/97972 + ThemeData themeData = ThemeData(); + themeData = ThemeData(checkboxTheme: CheckboxThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + ),radioTheme: RadioThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + ),switchTheme: SwitchThemeData( + thumbColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + trackColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + )); + themeData = ThemeData( + checkboxTheme: CheckboxThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + ),radioTheme: RadioThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + ),switchTheme: SwitchThemeData( + thumbColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + trackColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + ), + ); + themeData = ThemeData.raw(checkboxTheme: CheckboxThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + ),radioTheme: RadioThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + ),switchTheme: SwitchThemeData( + thumbColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + trackColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + )); + themeData = ThemeData.raw( + checkboxTheme: CheckboxThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + ),radioTheme: RadioThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + ),switchTheme: SwitchThemeData( + thumbColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + trackColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + ), + ); + themeData = themeData.copyWith(checkboxTheme: CheckboxThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + ),radioTheme: RadioThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + ),switchTheme: SwitchThemeData( + thumbColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + trackColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + )); + themeData = themeData.copyWith( + checkboxTheme: CheckboxThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + ),radioTheme: RadioThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + ),switchTheme: SwitchThemeData( + thumbColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + trackColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + ), + ); + themeData.toggleableActiveColor; // Removing field reference not supported. } From 9c45292b64a69b4762da54ad3b66a1fbf4c9b904 Mon Sep 17 00:00:00 2001 From: Taha Tesser Date: Tue, 2 Aug 2022 19:09:10 +0300 Subject: [PATCH 2/3] Update commas --- packages/flutter/lib/fix_data.yaml | 24 +++++----- .../flutter/test_fixes/material.dart.expect | 44 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/packages/flutter/lib/fix_data.yaml b/packages/flutter/lib/fix_data.yaml index 8e1c5eec056fd..9ab97a1a377ae 100644 --- a/packages/flutter/lib/fix_data.yaml +++ b/packages/flutter/lib/fix_data.yaml @@ -42,7 +42,7 @@ transforms: }\n return null;\n }),\n - )," + )" requiredIf: "toggleableActiveColor != '' && checkboxTheme == ''" - kind: 'addParameter' index: 97 @@ -59,7 +59,7 @@ transforms: }\n return null;\n }),\n - )," + )" requiredIf: "toggleableActiveColor != '' && checkboxTheme != ''" - kind: 'addParameter' index: 98 @@ -76,7 +76,7 @@ transforms: }\n return null;\n }),\n - )," + )" requiredIf: "toggleableActiveColor != '' && radioTheme == ''" - kind: 'addParameter' index: 99 @@ -93,7 +93,7 @@ transforms: }\n return null;\n }),\n - )," + )" requiredIf: "toggleableActiveColor != '' && radioTheme != ''" - kind: 'addParameter' index: 100 @@ -186,7 +186,7 @@ transforms: }\n return null;\n }),\n - )," + )" requiredIf: "toggleableActiveColor != '' && checkboxTheme == ''" - kind: 'addParameter' index: 97 @@ -203,7 +203,7 @@ transforms: }\n return null;\n }),\n - )," + )" requiredIf: "toggleableActiveColor != '' && checkboxTheme != ''" - kind: 'addParameter' index: 98 @@ -220,7 +220,7 @@ transforms: }\n return null;\n }),\n - )," + )" requiredIf: "toggleableActiveColor != '' && radioTheme == ''" - kind: 'addParameter' index: 99 @@ -237,7 +237,7 @@ transforms: }\n return null;\n }),\n - )," + )" requiredIf: "toggleableActiveColor != '' && radioTheme != ''" - kind: 'addParameter' index: 100 @@ -330,7 +330,7 @@ transforms: }\n return null;\n }),\n - )," + )" requiredIf: "toggleableActiveColor != '' && checkboxTheme == ''" - kind: 'addParameter' index: 97 @@ -347,7 +347,7 @@ transforms: }\n return null;\n }),\n - )," + )" requiredIf: "toggleableActiveColor != '' && checkboxTheme != ''" - kind: 'addParameter' index: 98 @@ -364,7 +364,7 @@ transforms: }\n return null;\n }),\n - )," + )" requiredIf: "toggleableActiveColor != '' && radioTheme == ''" - kind: 'addParameter' index: 99 @@ -433,7 +433,7 @@ transforms: }\n return null;\n }),\n - )," + )" requiredIf: "toggleableActiveColor != '' && switchTheme != ''" variables: checkboxTheme: diff --git a/packages/flutter/test_fixes/material.dart.expect b/packages/flutter/test_fixes/material.dart.expect index 4706bc8d03c9f..1b7a7c5934457 100644 --- a/packages/flutter/test_fixes/material.dart.expect +++ b/packages/flutter/test_fixes/material.dart.expect @@ -542,6 +542,16 @@ void main() { // Changes made in https://github.com/flutter/flutter/pull/97972 ThemeData themeData = ThemeData(); themeData = ThemeData(checkboxTheme: CheckboxThemeData( + fillColor: MaterialStateProperty.resolveWith((Set states) { + if (states.contains(MaterialState.disabled)) { + return null; + } + if (states.contains(MaterialState.selected)) { + return Colors.black; + } + return null; + }), + )radioTheme: RadioThemeData( fillColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -551,17 +561,7 @@ void main() { } return null; }), - ),radioTheme: RadioThemeData( - fillColor: MaterialStateProperty.resolveWith((Set states) { - if (states.contains(MaterialState.disabled)) { - return null; - } - if (states.contains(MaterialState.selected)) { - return Colors.black; - } - return null; - }), - ),switchTheme: SwitchThemeData( + )switchTheme: SwitchThemeData( thumbColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -592,7 +592,7 @@ void main() { } return null; }), - ),radioTheme: RadioThemeData( + )radioTheme: RadioThemeData( fillColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -602,7 +602,7 @@ void main() { } return null; }), - ),switchTheme: SwitchThemeData( + )switchTheme: SwitchThemeData( thumbColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -633,7 +633,7 @@ void main() { } return null; }), - ),radioTheme: RadioThemeData( + )radioTheme: RadioThemeData( fillColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -643,7 +643,7 @@ void main() { } return null; }), - ),switchTheme: SwitchThemeData( + )switchTheme: SwitchThemeData( thumbColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -663,7 +663,7 @@ void main() { return null; }), )); - themeData = ThemeData.raw( + themeData = ThemeData.raw( checkboxTheme: CheckboxThemeData( fillColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { @@ -674,7 +674,7 @@ void main() { } return null; }), - ),radioTheme: RadioThemeData( + )radioTheme: RadioThemeData( fillColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -684,7 +684,7 @@ void main() { } return null; }), - ),switchTheme: SwitchThemeData( + )switchTheme: SwitchThemeData( thumbColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -715,7 +715,7 @@ void main() { } return null; }), - ),radioTheme: RadioThemeData( + )radioTheme: RadioThemeData( fillColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -725,7 +725,7 @@ void main() { } return null; }), - ),switchTheme: SwitchThemeData( + )switchTheme: SwitchThemeData( thumbColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -756,7 +756,7 @@ void main() { } return null; }), - ),radioTheme: RadioThemeData( + )radioTheme: RadioThemeData( fillColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -766,7 +766,7 @@ void main() { } return null; }), - ),switchTheme: SwitchThemeData( + )switchTheme: SwitchThemeData( thumbColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; From 018bc1780566e77d2aaaf8fada8a7196abbd32d2 Mon Sep 17 00:00:00 2001 From: Taha Tesser Date: Tue, 2 Aug 2022 20:08:15 +0300 Subject: [PATCH 3/3] fix commas --- .../flutter/test_fixes/material.dart.expect | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/flutter/test_fixes/material.dart.expect b/packages/flutter/test_fixes/material.dart.expect index 1b7a7c5934457..b9fcf147db7d1 100644 --- a/packages/flutter/test_fixes/material.dart.expect +++ b/packages/flutter/test_fixes/material.dart.expect @@ -551,7 +551,7 @@ void main() { } return null; }), - )radioTheme: RadioThemeData( + ), radioTheme: RadioThemeData( fillColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -561,7 +561,7 @@ void main() { } return null; }), - )switchTheme: SwitchThemeData( + ), switchTheme: SwitchThemeData( thumbColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -592,7 +592,7 @@ void main() { } return null; }), - )radioTheme: RadioThemeData( + ), radioTheme: RadioThemeData( fillColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -602,7 +602,7 @@ void main() { } return null; }), - )switchTheme: SwitchThemeData( + ), switchTheme: SwitchThemeData( thumbColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -633,7 +633,7 @@ void main() { } return null; }), - )radioTheme: RadioThemeData( + ), radioTheme: RadioThemeData( fillColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -643,7 +643,7 @@ void main() { } return null; }), - )switchTheme: SwitchThemeData( + ), switchTheme: SwitchThemeData( thumbColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -674,7 +674,7 @@ void main() { } return null; }), - )radioTheme: RadioThemeData( + ), radioTheme: RadioThemeData( fillColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -684,7 +684,7 @@ void main() { } return null; }), - )switchTheme: SwitchThemeData( + ), switchTheme: SwitchThemeData( thumbColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -715,7 +715,7 @@ void main() { } return null; }), - )radioTheme: RadioThemeData( + ), radioTheme: RadioThemeData( fillColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -725,7 +725,7 @@ void main() { } return null; }), - )switchTheme: SwitchThemeData( + ), switchTheme: SwitchThemeData( thumbColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -756,7 +756,7 @@ void main() { } return null; }), - )radioTheme: RadioThemeData( + ), radioTheme: RadioThemeData( fillColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null; @@ -766,7 +766,7 @@ void main() { } return null; }), - )switchTheme: SwitchThemeData( + ), switchTheme: SwitchThemeData( thumbColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return null;