Unverified Commit 1349c591 authored by Qun Cheng's avatar Qun Cheng Committed by GitHub

Remove `toggleableActiveColor` from `ThemeData` (#144178)

This PR is to remove deprecated ThemeData.toggleableActiveColor.

These parameters are made obsolete in https://github.com/flutter/flutter/pull/97972.
Part of https://github.com/flutter/flutter/pull/111080
parent 726e5d28
...@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:gallery/themes/material_demo_theme_data.dart'; import 'package:gallery/themes/material_demo_theme_data.dart';
void main() { void main() {
test('verify former toggleableActiveColor themes are set', () async { test('verify the activeColors of toggleable widget themes are set', () async {
const Color primaryColor = Color(0xFF6200EE); const Color primaryColor = Color(0xFF6200EE);
final ThemeData themeData = MaterialDemoThemeData.themeData; final ThemeData themeData = MaterialDemoThemeData.themeData;
......
...@@ -260,10 +260,12 @@ class Radio<T> extends StatefulWidget { ...@@ -260,10 +260,12 @@ class Radio<T> extends StatefulWidget {
/// ///
/// If null, then the value of [activeColor] is used in the selected state. If /// 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. /// that is also null, then the value of [RadioThemeData.fillColor] is used.
/// If that is also null, then [ThemeData.disabledColor] is used in /// If that is also null and [ThemeData.useMaterial3] is false, then
/// the disabled state, [ColorScheme.secondary] is used in the /// [ThemeData.disabledColor] is used in the disabled state, [ColorScheme.secondary]
/// selected state, and [ThemeData.unselectedWidgetColor] is used in the /// is used in the selected state, and [ThemeData.unselectedWidgetColor] is used in the
/// default state. /// default state; if [ThemeData.useMaterial3] is true, then [ColorScheme.onSurface]
/// is used in the disabled state, [ColorScheme.primary] is used in the
/// selected state and [ColorScheme.onSurfaceVariant] is used in the default state.
final MaterialStateProperty<Color?>? fillColor; final MaterialStateProperty<Color?>? fillColor;
/// {@template flutter.material.radio.materialTapTargetSize} /// {@template flutter.material.radio.materialTapTargetSize}
......
...@@ -34,8 +34,8 @@ enum _RadioType { material, adaptive } ...@@ -34,8 +34,8 @@ enum _RadioType { material, adaptive }
/// those of the same name on [ListTile]. /// those of the same name on [ListTile].
/// ///
/// The [selected] property on this widget is similar to the [ListTile.selected] /// 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 /// property. The [fillColor] in the selected state is used for the selected item's
/// the theme's [ThemeData.toggleableActiveColor] if [activeColor] is null. /// text color. It it is null, the [activeColor] is used.
/// ///
/// This widget does not coordinate the [selected] state and the /// This widget does not coordinate the [selected] state and the
/// [checked] state; to have the list tile appear selected when the /// [checked] state; to have the list tile appear selected when the
......
...@@ -55,18 +55,12 @@ class RadioThemeData with Diagnosticable { ...@@ -55,18 +55,12 @@ class RadioThemeData with Diagnosticable {
/// {@macro flutter.material.radio.fillColor} /// {@macro flutter.material.radio.fillColor}
/// ///
/// If specified, overrides the default value of [Radio.fillColor]. The /// If specified, overrides the default value of [Radio.fillColor].
/// default value is the value of [ThemeData.disabledColor] in the disabled
/// state, [ThemeData.toggleableActiveColor] in the selected state, and
/// [ThemeData.unselectedWidgetColor] in the default state.
final MaterialStateProperty<Color?>? fillColor; final MaterialStateProperty<Color?>? fillColor;
/// {@macro flutter.material.radio.overlayColor} /// {@macro flutter.material.radio.overlayColor}
/// ///
/// If specified, overrides the default value of [Radio.overlayColor]. The /// If specified, overrides the default value of [Radio.overlayColor].
/// default value is [ThemeData.toggleableActiveColor] with alpha
/// [kRadialReactionAlpha], [ThemeData.focusColor] and [ThemeData.hoverColor]
/// in the pressed, focused, and hovered state.
final MaterialStateProperty<Color?>? overlayColor; final MaterialStateProperty<Color?>? overlayColor;
/// {@macro flutter.material.radio.splashRadius} /// {@macro flutter.material.radio.splashRadius}
......
...@@ -297,7 +297,7 @@ class SwitchListTile extends StatelessWidget { ...@@ -297,7 +297,7 @@ class SwitchListTile extends StatelessWidget {
/// {@macro flutter.material.switch.activeTrackColor} /// {@macro flutter.material.switch.activeTrackColor}
/// ///
/// Defaults to [ThemeData.toggleableActiveColor] with the opacity set at 50%. /// Defaults to [ColorScheme.secondary] with the opacity set at 50%.
/// ///
/// Ignored if created with [SwitchListTile.adaptive]. /// Ignored if created with [SwitchListTile.adaptive].
final Color? activeTrackColor; final Color? activeTrackColor;
......
...@@ -367,13 +367,6 @@ class ThemeData with Diagnosticable { ...@@ -367,13 +367,6 @@ class ThemeData with Diagnosticable {
ToggleButtonsThemeData? toggleButtonsTheme, ToggleButtonsThemeData? toggleButtonsTheme,
TooltipThemeData? tooltipTheme, TooltipThemeData? tooltipTheme,
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
@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 v3.4.0-19.0.pre.',
)
Color? toggleableActiveColor,
@Deprecated( @Deprecated(
'Use colorScheme.error instead. ' 'Use colorScheme.error instead. '
'This feature was deprecated after v3.3.0-0.5.pre.', 'This feature was deprecated after v3.3.0-0.5.pre.',
...@@ -451,7 +444,6 @@ class ThemeData with Diagnosticable { ...@@ -451,7 +444,6 @@ class ThemeData with Diagnosticable {
primaryColorLight ??= isDark ? Colors.grey[500]! : primarySwatch[100]!; primaryColorLight ??= isDark ? Colors.grey[500]! : primarySwatch[100]!;
primaryColorDark ??= isDark ? Colors.black : primarySwatch[700]!; primaryColorDark ??= isDark ? Colors.black : primarySwatch[700]!;
final bool primaryIsDark = estimatedPrimaryColorBrightness == Brightness.dark; final bool primaryIsDark = estimatedPrimaryColorBrightness == Brightness.dark;
toggleableActiveColor ??= isDark ? Colors.tealAccent[200]! : (colorScheme?.secondary ?? primarySwatch[600]!);
focusColor ??= isDark ? Colors.white.withOpacity(0.12) : Colors.black.withOpacity(0.12); focusColor ??= isDark ? Colors.white.withOpacity(0.12) : Colors.black.withOpacity(0.12);
hoverColor ??= isDark ? Colors.white.withOpacity(0.04) : Colors.black.withOpacity(0.04); hoverColor ??= isDark ? Colors.white.withOpacity(0.04) : Colors.black.withOpacity(0.04);
shadowColor ??= Colors.black; shadowColor ??= Colors.black;
...@@ -657,7 +649,6 @@ class ThemeData with Diagnosticable { ...@@ -657,7 +649,6 @@ class ThemeData with Diagnosticable {
toggleButtonsTheme: toggleButtonsTheme, toggleButtonsTheme: toggleButtonsTheme,
tooltipTheme: tooltipTheme, tooltipTheme: tooltipTheme,
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
toggleableActiveColor: toggleableActiveColor,
errorColor: errorColor, errorColor: errorColor,
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
); );
...@@ -766,13 +757,6 @@ class ThemeData with Diagnosticable { ...@@ -766,13 +757,6 @@ class ThemeData with Diagnosticable {
required this.toggleButtonsTheme, required this.toggleButtonsTheme,
required this.tooltipTheme, required this.tooltipTheme,
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
@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 v3.4.0-19.0.pre.',
)
Color? toggleableActiveColor,
@Deprecated( @Deprecated(
'Use colorScheme.error instead. ' 'Use colorScheme.error instead. '
'This feature was deprecated after v3.3.0-0.5.pre.', 'This feature was deprecated after v3.3.0-0.5.pre.',
...@@ -786,10 +770,8 @@ class ThemeData with Diagnosticable { ...@@ -786,10 +770,8 @@ class ThemeData with Diagnosticable {
}) : // DEPRECATED (newest deprecations at the bottom) }) : // DEPRECATED (newest deprecations at the bottom)
// should not be `required`, use getter pattern to avoid breakages. // should not be `required`, use getter pattern to avoid breakages.
_toggleableActiveColor = toggleableActiveColor,
_errorColor = errorColor, _errorColor = errorColor,
_backgroundColor = backgroundColor, _backgroundColor = backgroundColor,
assert(toggleableActiveColor != null),
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
assert(errorColor != null), assert(errorColor != null),
assert(backgroundColor != null); assert(backgroundColor != null);
...@@ -1469,17 +1451,6 @@ class ThemeData with Diagnosticable { ...@@ -1469,17 +1451,6 @@ class ThemeData with Diagnosticable {
Color get backgroundColor => _backgroundColor!; Color get backgroundColor => _backgroundColor!;
final Color? _backgroundColor; final Color? _backgroundColor;
/// The color used to highlight the active states of toggleable widgets like
/// [Switch], [Radio], and [Checkbox].
@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 v3.4.0-19.0.pre.',
)
Color get toggleableActiveColor => _toggleableActiveColor!;
final Color? _toggleableActiveColor;
/// Creates a copy of this theme but with the given fields replaced with the new values. /// Creates a copy of this theme but with the given fields replaced with the new values.
/// ///
/// The [brightness] value is applied to the [colorScheme]. /// The [brightness] value is applied to the [colorScheme].
...@@ -1579,13 +1550,6 @@ class ThemeData with Diagnosticable { ...@@ -1579,13 +1550,6 @@ class ThemeData with Diagnosticable {
ToggleButtonsThemeData? toggleButtonsTheme, ToggleButtonsThemeData? toggleButtonsTheme,
TooltipThemeData? tooltipTheme, TooltipThemeData? tooltipTheme,
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
@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 v3.4.0-19.0.pre.',
)
Color? toggleableActiveColor,
@Deprecated( @Deprecated(
'Use colorScheme.error instead. ' 'Use colorScheme.error instead. '
'This feature was deprecated after v3.3.0-0.5.pre.', 'This feature was deprecated after v3.3.0-0.5.pre.',
...@@ -1701,7 +1665,6 @@ class ThemeData with Diagnosticable { ...@@ -1701,7 +1665,6 @@ class ThemeData with Diagnosticable {
toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme, toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme,
tooltipTheme: tooltipTheme ?? this.tooltipTheme, tooltipTheme: tooltipTheme ?? this.tooltipTheme,
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
toggleableActiveColor: toggleableActiveColor ?? _toggleableActiveColor,
errorColor: errorColor ?? _errorColor, errorColor: errorColor ?? _errorColor,
backgroundColor: backgroundColor ?? _backgroundColor, backgroundColor: backgroundColor ?? _backgroundColor,
); );
...@@ -1898,7 +1861,6 @@ class ThemeData with Diagnosticable { ...@@ -1898,7 +1861,6 @@ class ThemeData with Diagnosticable {
toggleButtonsTheme: ToggleButtonsThemeData.lerp(a.toggleButtonsTheme, b.toggleButtonsTheme, t)!, toggleButtonsTheme: ToggleButtonsThemeData.lerp(a.toggleButtonsTheme, b.toggleButtonsTheme, t)!,
tooltipTheme: TooltipThemeData.lerp(a.tooltipTheme, b.tooltipTheme, t)!, tooltipTheme: TooltipThemeData.lerp(a.tooltipTheme, b.tooltipTheme, t)!,
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
toggleableActiveColor: Color.lerp(a.toggleableActiveColor, b.toggleableActiveColor, t),
errorColor: Color.lerp(a.errorColor, b.errorColor, t), errorColor: Color.lerp(a.errorColor, b.errorColor, t),
backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t), backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t),
); );
...@@ -2002,7 +1964,6 @@ class ThemeData with Diagnosticable { ...@@ -2002,7 +1964,6 @@ class ThemeData with Diagnosticable {
other.toggleButtonsTheme == toggleButtonsTheme && other.toggleButtonsTheme == toggleButtonsTheme &&
other.tooltipTheme == tooltipTheme && other.tooltipTheme == tooltipTheme &&
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
other.toggleableActiveColor == toggleableActiveColor &&
other.errorColor == errorColor && other.errorColor == errorColor &&
other.backgroundColor == backgroundColor; other.backgroundColor == backgroundColor;
} }
...@@ -2104,7 +2065,6 @@ class ThemeData with Diagnosticable { ...@@ -2104,7 +2065,6 @@ class ThemeData with Diagnosticable {
toggleButtonsTheme, toggleButtonsTheme,
tooltipTheme, tooltipTheme,
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
toggleableActiveColor,
errorColor, errorColor,
backgroundColor, backgroundColor,
]; ];
...@@ -2207,7 +2167,6 @@ class ThemeData with Diagnosticable { ...@@ -2207,7 +2167,6 @@ class ThemeData with Diagnosticable {
properties.add(DiagnosticsProperty<ToggleButtonsThemeData>('toggleButtonsTheme', toggleButtonsTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<ToggleButtonsThemeData>('toggleButtonsTheme', toggleButtonsTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<TooltipThemeData>('tooltipTheme', tooltipTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<TooltipThemeData>('tooltipTheme', tooltipTheme, level: DiagnosticLevel.debug));
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
properties.add(ColorProperty('toggleableActiveColor', toggleableActiveColor, defaultValue: defaultData.toggleableActiveColor, level: DiagnosticLevel.debug));
properties.add(ColorProperty('errorColor', errorColor, defaultValue: defaultData.errorColor, level: DiagnosticLevel.debug)); properties.add(ColorProperty('errorColor', errorColor, defaultValue: defaultData.errorColor, level: DiagnosticLevel.debug));
properties.add(ColorProperty('backgroundColor', backgroundColor, defaultValue: defaultData.backgroundColor, level: DiagnosticLevel.debug)); properties.add(ColorProperty('backgroundColor', backgroundColor, defaultValue: defaultData.backgroundColor, level: DiagnosticLevel.debug));
} }
......
...@@ -642,7 +642,6 @@ void main() { ...@@ -642,7 +642,6 @@ void main() {
indicatorColor: Colors.black, indicatorColor: Colors.black,
hintColor: Colors.black, hintColor: Colors.black,
errorColor: Colors.black, errorColor: Colors.black,
toggleableActiveColor: Colors.black,
textTheme: ThemeData.dark().textTheme, textTheme: ThemeData.dark().textTheme,
primaryTextTheme: ThemeData.dark().textTheme, primaryTextTheme: ThemeData.dark().textTheme,
inputDecorationTheme: ThemeData.dark().inputDecorationTheme.copyWith(border: const OutlineInputBorder()), inputDecorationTheme: ThemeData.dark().inputDecorationTheme.copyWith(border: const OutlineInputBorder()),
......
...@@ -902,7 +902,6 @@ void main() { ...@@ -902,7 +902,6 @@ void main() {
toggleButtonsTheme: const ToggleButtonsThemeData(textStyle: TextStyle(color: Colors.black)), toggleButtonsTheme: const ToggleButtonsThemeData(textStyle: TextStyle(color: Colors.black)),
tooltipTheme: const TooltipThemeData(height: 100), tooltipTheme: const TooltipThemeData(height: 100),
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
toggleableActiveColor: Colors.black,
errorColor: Colors.black, errorColor: Colors.black,
backgroundColor: Colors.black, backgroundColor: Colors.black,
); );
...@@ -1021,7 +1020,6 @@ void main() { ...@@ -1021,7 +1020,6 @@ void main() {
tooltipTheme: const TooltipThemeData(height: 100), tooltipTheme: const TooltipThemeData(height: 100),
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
toggleableActiveColor: Colors.white,
errorColor: Colors.white, errorColor: Colors.white,
backgroundColor: Colors.white, backgroundColor: Colors.white,
); );
...@@ -1121,7 +1119,6 @@ void main() { ...@@ -1121,7 +1119,6 @@ void main() {
tooltipTheme: otherTheme.tooltipTheme, tooltipTheme: otherTheme.tooltipTheme,
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
toggleableActiveColor: otherTheme.toggleableActiveColor,
errorColor: otherTheme.errorColor, errorColor: otherTheme.errorColor,
backgroundColor: otherTheme.backgroundColor, backgroundColor: otherTheme.backgroundColor,
); );
...@@ -1222,7 +1219,6 @@ void main() { ...@@ -1222,7 +1219,6 @@ void main() {
expect(themeDataCopy.tooltipTheme, equals(otherTheme.tooltipTheme)); expect(themeDataCopy.tooltipTheme, equals(otherTheme.tooltipTheme));
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
expect(themeDataCopy.toggleableActiveColor, equals(otherTheme.toggleableActiveColor));
expect(themeDataCopy.errorColor, equals(otherTheme.errorColor)); expect(themeDataCopy.errorColor, equals(otherTheme.errorColor));
expect(themeDataCopy.backgroundColor, equals(otherTheme.backgroundColor)); expect(themeDataCopy.backgroundColor, equals(otherTheme.backgroundColor));
}); });
...@@ -1354,7 +1350,6 @@ void main() { ...@@ -1354,7 +1350,6 @@ void main() {
'toggleButtonsTheme', 'toggleButtonsTheme',
'tooltipTheme', 'tooltipTheme',
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
'toggleableActiveColor',
'errorColor', 'errorColor',
'backgroundColor', 'backgroundColor',
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment