Skip to content

Commit 1349c59

Browse files
authored
Remove toggleableActiveColor from ThemeData (#144178)
This PR is to remove deprecated ThemeData.toggleableActiveColor. These parameters are made obsolete in flutter/flutter#97972. Part of flutter/flutter#111080
1 parent 726e5d2 commit 1349c59

File tree

8 files changed

+12
-63
lines changed

8 files changed

+12
-63
lines changed

dev/integration_tests/new_gallery/test/theme_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
77
import 'package:gallery/themes/material_demo_theme_data.dart';
88

99
void main() {
10-
test('verify former toggleableActiveColor themes are set', () async {
10+
test('verify the activeColors of toggleable widget themes are set', () async {
1111
const Color primaryColor = Color(0xFF6200EE);
1212
final ThemeData themeData = MaterialDemoThemeData.themeData;
1313

packages/flutter/lib/src/material/radio.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,12 @@ class Radio<T> extends StatefulWidget {
260260
///
261261
/// If null, then the value of [activeColor] is used in the selected state. If
262262
/// that is also null, then the value of [RadioThemeData.fillColor] is used.
263-
/// If that is also null, then [ThemeData.disabledColor] is used in
264-
/// the disabled state, [ColorScheme.secondary] is used in the
265-
/// selected state, and [ThemeData.unselectedWidgetColor] is used in the
266-
/// default state.
263+
/// If that is also null and [ThemeData.useMaterial3] is false, then
264+
/// [ThemeData.disabledColor] is used in the disabled state, [ColorScheme.secondary]
265+
/// is used in the selected state, and [ThemeData.unselectedWidgetColor] is used in the
266+
/// default state; if [ThemeData.useMaterial3] is true, then [ColorScheme.onSurface]
267+
/// is used in the disabled state, [ColorScheme.primary] is used in the
268+
/// selected state and [ColorScheme.onSurfaceVariant] is used in the default state.
267269
final MaterialStateProperty<Color?>? fillColor;
268270

269271
/// {@template flutter.material.radio.materialTapTargetSize}

packages/flutter/lib/src/material/radio_list_tile.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ enum _RadioType { material, adaptive }
3434
/// those of the same name on [ListTile].
3535
///
3636
/// The [selected] property on this widget is similar to the [ListTile.selected]
37-
/// property. This tile's [activeColor] is used for the selected item's text color, or
38-
/// the theme's [ThemeData.toggleableActiveColor] if [activeColor] is null.
37+
/// property. The [fillColor] in the selected state is used for the selected item's
38+
/// text color. It it is null, the [activeColor] is used.
3939
///
4040
/// This widget does not coordinate the [selected] state and the
4141
/// [checked] state; to have the list tile appear selected when the

packages/flutter/lib/src/material/radio_theme.dart

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,12 @@ class RadioThemeData with Diagnosticable {
5555

5656
/// {@macro flutter.material.radio.fillColor}
5757
///
58-
/// If specified, overrides the default value of [Radio.fillColor]. The
59-
/// default value is the value of [ThemeData.disabledColor] in the disabled
60-
/// state, [ThemeData.toggleableActiveColor] in the selected state, and
61-
/// [ThemeData.unselectedWidgetColor] in the default state.
58+
/// If specified, overrides the default value of [Radio.fillColor].
6259
final MaterialStateProperty<Color?>? fillColor;
6360

6461
/// {@macro flutter.material.radio.overlayColor}
6562
///
66-
/// If specified, overrides the default value of [Radio.overlayColor]. The
67-
/// default value is [ThemeData.toggleableActiveColor] with alpha
68-
/// [kRadialReactionAlpha], [ThemeData.focusColor] and [ThemeData.hoverColor]
69-
/// in the pressed, focused, and hovered state.
63+
/// If specified, overrides the default value of [Radio.overlayColor].
7064
final MaterialStateProperty<Color?>? overlayColor;
7165

7266
/// {@macro flutter.material.radio.splashRadius}

packages/flutter/lib/src/material/switch_list_tile.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ class SwitchListTile extends StatelessWidget {
297297

298298
/// {@macro flutter.material.switch.activeTrackColor}
299299
///
300-
/// Defaults to [ThemeData.toggleableActiveColor] with the opacity set at 50%.
300+
/// Defaults to [ColorScheme.secondary] with the opacity set at 50%.
301301
///
302302
/// Ignored if created with [SwitchListTile.adaptive].
303303
final Color? activeTrackColor;

packages/flutter/lib/src/material/theme_data.dart

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,6 @@ class ThemeData with Diagnosticable {
367367
ToggleButtonsThemeData? toggleButtonsTheme,
368368
TooltipThemeData? tooltipTheme,
369369
// DEPRECATED (newest deprecations at the bottom)
370-
@Deprecated(
371-
'No longer used by the framework, please remove any reference to it. '
372-
'For more information, consult the migration guide at '
373-
'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. '
374-
'This feature was deprecated after v3.4.0-19.0.pre.',
375-
)
376-
Color? toggleableActiveColor,
377370
@Deprecated(
378371
'Use colorScheme.error instead. '
379372
'This feature was deprecated after v3.3.0-0.5.pre.',
@@ -451,7 +444,6 @@ class ThemeData with Diagnosticable {
451444
primaryColorLight ??= isDark ? Colors.grey[500]! : primarySwatch[100]!;
452445
primaryColorDark ??= isDark ? Colors.black : primarySwatch[700]!;
453446
final bool primaryIsDark = estimatedPrimaryColorBrightness == Brightness.dark;
454-
toggleableActiveColor ??= isDark ? Colors.tealAccent[200]! : (colorScheme?.secondary ?? primarySwatch[600]!);
455447
focusColor ??= isDark ? Colors.white.withOpacity(0.12) : Colors.black.withOpacity(0.12);
456448
hoverColor ??= isDark ? Colors.white.withOpacity(0.04) : Colors.black.withOpacity(0.04);
457449
shadowColor ??= Colors.black;
@@ -657,7 +649,6 @@ class ThemeData with Diagnosticable {
657649
toggleButtonsTheme: toggleButtonsTheme,
658650
tooltipTheme: tooltipTheme,
659651
// DEPRECATED (newest deprecations at the bottom)
660-
toggleableActiveColor: toggleableActiveColor,
661652
errorColor: errorColor,
662653
backgroundColor: backgroundColor,
663654
);
@@ -766,13 +757,6 @@ class ThemeData with Diagnosticable {
766757
required this.toggleButtonsTheme,
767758
required this.tooltipTheme,
768759
// DEPRECATED (newest deprecations at the bottom)
769-
@Deprecated(
770-
'No longer used by the framework, please remove any reference to it. '
771-
'For more information, consult the migration guide at '
772-
'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. '
773-
'This feature was deprecated after v3.4.0-19.0.pre.',
774-
)
775-
Color? toggleableActiveColor,
776760
@Deprecated(
777761
'Use colorScheme.error instead. '
778762
'This feature was deprecated after v3.3.0-0.5.pre.',
@@ -786,10 +770,8 @@ class ThemeData with Diagnosticable {
786770

787771
}) : // DEPRECATED (newest deprecations at the bottom)
788772
// should not be `required`, use getter pattern to avoid breakages.
789-
_toggleableActiveColor = toggleableActiveColor,
790773
_errorColor = errorColor,
791774
_backgroundColor = backgroundColor,
792-
assert(toggleableActiveColor != null),
793775
// DEPRECATED (newest deprecations at the bottom)
794776
assert(errorColor != null),
795777
assert(backgroundColor != null);
@@ -1469,17 +1451,6 @@ class ThemeData with Diagnosticable {
14691451
Color get backgroundColor => _backgroundColor!;
14701452
final Color? _backgroundColor;
14711453

1472-
/// The color used to highlight the active states of toggleable widgets like
1473-
/// [Switch], [Radio], and [Checkbox].
1474-
@Deprecated(
1475-
'No longer used by the framework, please remove any reference to it. '
1476-
'For more information, consult the migration guide at '
1477-
'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. '
1478-
'This feature was deprecated after v3.4.0-19.0.pre.',
1479-
)
1480-
Color get toggleableActiveColor => _toggleableActiveColor!;
1481-
final Color? _toggleableActiveColor;
1482-
14831454
/// Creates a copy of this theme but with the given fields replaced with the new values.
14841455
///
14851456
/// The [brightness] value is applied to the [colorScheme].
@@ -1579,13 +1550,6 @@ class ThemeData with Diagnosticable {
15791550
ToggleButtonsThemeData? toggleButtonsTheme,
15801551
TooltipThemeData? tooltipTheme,
15811552
// DEPRECATED (newest deprecations at the bottom)
1582-
@Deprecated(
1583-
'No longer used by the framework, please remove any reference to it. '
1584-
'For more information, consult the migration guide at '
1585-
'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. '
1586-
'This feature was deprecated after v3.4.0-19.0.pre.',
1587-
)
1588-
Color? toggleableActiveColor,
15891553
@Deprecated(
15901554
'Use colorScheme.error instead. '
15911555
'This feature was deprecated after v3.3.0-0.5.pre.',
@@ -1701,7 +1665,6 @@ class ThemeData with Diagnosticable {
17011665
toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme,
17021666
tooltipTheme: tooltipTheme ?? this.tooltipTheme,
17031667
// DEPRECATED (newest deprecations at the bottom)
1704-
toggleableActiveColor: toggleableActiveColor ?? _toggleableActiveColor,
17051668
errorColor: errorColor ?? _errorColor,
17061669
backgroundColor: backgroundColor ?? _backgroundColor,
17071670
);
@@ -1898,7 +1861,6 @@ class ThemeData with Diagnosticable {
18981861
toggleButtonsTheme: ToggleButtonsThemeData.lerp(a.toggleButtonsTheme, b.toggleButtonsTheme, t)!,
18991862
tooltipTheme: TooltipThemeData.lerp(a.tooltipTheme, b.tooltipTheme, t)!,
19001863
// DEPRECATED (newest deprecations at the bottom)
1901-
toggleableActiveColor: Color.lerp(a.toggleableActiveColor, b.toggleableActiveColor, t),
19021864
errorColor: Color.lerp(a.errorColor, b.errorColor, t),
19031865
backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t),
19041866
);
@@ -2002,7 +1964,6 @@ class ThemeData with Diagnosticable {
20021964
other.toggleButtonsTheme == toggleButtonsTheme &&
20031965
other.tooltipTheme == tooltipTheme &&
20041966
// DEPRECATED (newest deprecations at the bottom)
2005-
other.toggleableActiveColor == toggleableActiveColor &&
20061967
other.errorColor == errorColor &&
20071968
other.backgroundColor == backgroundColor;
20081969
}
@@ -2104,7 +2065,6 @@ class ThemeData with Diagnosticable {
21042065
toggleButtonsTheme,
21052066
tooltipTheme,
21062067
// DEPRECATED (newest deprecations at the bottom)
2107-
toggleableActiveColor,
21082068
errorColor,
21092069
backgroundColor,
21102070
];
@@ -2207,7 +2167,6 @@ class ThemeData with Diagnosticable {
22072167
properties.add(DiagnosticsProperty<ToggleButtonsThemeData>('toggleButtonsTheme', toggleButtonsTheme, level: DiagnosticLevel.debug));
22082168
properties.add(DiagnosticsProperty<TooltipThemeData>('tooltipTheme', tooltipTheme, level: DiagnosticLevel.debug));
22092169
// DEPRECATED (newest deprecations at the bottom)
2210-
properties.add(ColorProperty('toggleableActiveColor', toggleableActiveColor, defaultValue: defaultData.toggleableActiveColor, level: DiagnosticLevel.debug));
22112170
properties.add(ColorProperty('errorColor', errorColor, defaultValue: defaultData.errorColor, level: DiagnosticLevel.debug));
22122171
properties.add(ColorProperty('backgroundColor', backgroundColor, defaultValue: defaultData.backgroundColor, level: DiagnosticLevel.debug));
22132172
}

packages/flutter/test/material/snack_bar_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,6 @@ void main() {
642642
indicatorColor: Colors.black,
643643
hintColor: Colors.black,
644644
errorColor: Colors.black,
645-
toggleableActiveColor: Colors.black,
646645
textTheme: ThemeData.dark().textTheme,
647646
primaryTextTheme: ThemeData.dark().textTheme,
648647
inputDecorationTheme: ThemeData.dark().inputDecorationTheme.copyWith(border: const OutlineInputBorder()),

packages/flutter/test/material/theme_data_test.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,6 @@ void main() {
902902
toggleButtonsTheme: const ToggleButtonsThemeData(textStyle: TextStyle(color: Colors.black)),
903903
tooltipTheme: const TooltipThemeData(height: 100),
904904
// DEPRECATED (newest deprecations at the bottom)
905-
toggleableActiveColor: Colors.black,
906905
errorColor: Colors.black,
907906
backgroundColor: Colors.black,
908907
);
@@ -1021,7 +1020,6 @@ void main() {
10211020
tooltipTheme: const TooltipThemeData(height: 100),
10221021

10231022
// DEPRECATED (newest deprecations at the bottom)
1024-
toggleableActiveColor: Colors.white,
10251023
errorColor: Colors.white,
10261024
backgroundColor: Colors.white,
10271025
);
@@ -1121,7 +1119,6 @@ void main() {
11211119
tooltipTheme: otherTheme.tooltipTheme,
11221120

11231121
// DEPRECATED (newest deprecations at the bottom)
1124-
toggleableActiveColor: otherTheme.toggleableActiveColor,
11251122
errorColor: otherTheme.errorColor,
11261123
backgroundColor: otherTheme.backgroundColor,
11271124
);
@@ -1222,7 +1219,6 @@ void main() {
12221219
expect(themeDataCopy.tooltipTheme, equals(otherTheme.tooltipTheme));
12231220

12241221
// DEPRECATED (newest deprecations at the bottom)
1225-
expect(themeDataCopy.toggleableActiveColor, equals(otherTheme.toggleableActiveColor));
12261222
expect(themeDataCopy.errorColor, equals(otherTheme.errorColor));
12271223
expect(themeDataCopy.backgroundColor, equals(otherTheme.backgroundColor));
12281224
});
@@ -1354,7 +1350,6 @@ void main() {
13541350
'toggleButtonsTheme',
13551351
'tooltipTheme',
13561352
// DEPRECATED (newest deprecations at the bottom)
1357-
'toggleableActiveColor',
13581353
'errorColor',
13591354
'backgroundColor',
13601355
};

0 commit comments

Comments
 (0)