Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove toggleableActiveColor from ThemeData #144178

Merged
merged 2 commits into from Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev/integration_tests/new_gallery/test/theme_test.dart
Expand Up @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:gallery/themes/material_demo_theme_data.dart';

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);
final ThemeData themeData = MaterialDemoThemeData.themeData;

Expand Down
10 changes: 6 additions & 4 deletions packages/flutter/lib/src/material/radio.dart
Expand Up @@ -260,10 +260,12 @@ class Radio<T> 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, [ColorScheme.secondary] is used in the
/// selected state, and [ThemeData.unselectedWidgetColor] is used in the
/// default state.
/// If that is also null and [ThemeData.useMaterial3] is false, then
/// [ThemeData.disabledColor] is used in the disabled state, [ColorScheme.secondary]
/// is used in the selected state, and [ThemeData.unselectedWidgetColor] is used in the
/// 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;

/// {@template flutter.material.radio.materialTapTargetSize}
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/lib/src/material/radio_list_tile.dart
Expand Up @@ -34,8 +34,8 @@ enum _RadioType { material, adaptive }
/// those of the same name on [ListTile].
///
/// 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.
/// property. The [fillColor] in the selected state is used for the selected item's
/// text color. It it is null, the [activeColor] is used.
///
/// This widget does not coordinate the [selected] state and the
/// [checked] state; to have the list tile appear selected when the
Expand Down
10 changes: 2 additions & 8 deletions packages/flutter/lib/src/material/radio_theme.dart
Expand Up @@ -55,18 +55,12 @@ class RadioThemeData with Diagnosticable {

/// {@macro flutter.material.radio.fillColor}
///
/// If specified, overrides the default value of [Radio.fillColor]. The
/// 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.
/// If specified, overrides the default value of [Radio.fillColor].
final MaterialStateProperty<Color?>? fillColor;

/// {@macro flutter.material.radio.overlayColor}
///
/// If specified, overrides the default value of [Radio.overlayColor]. The
/// default value is [ThemeData.toggleableActiveColor] with alpha
/// [kRadialReactionAlpha], [ThemeData.focusColor] and [ThemeData.hoverColor]
/// in the pressed, focused, and hovered state.
/// If specified, overrides the default value of [Radio.overlayColor].
final MaterialStateProperty<Color?>? overlayColor;

/// {@macro flutter.material.radio.splashRadius}
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/switch_list_tile.dart
Expand Up @@ -297,7 +297,7 @@ class SwitchListTile extends StatelessWidget {

/// {@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].
final Color? activeTrackColor;
Expand Down
41 changes: 0 additions & 41 deletions packages/flutter/lib/src/material/theme_data.dart
Expand Up @@ -367,13 +367,6 @@ class ThemeData with Diagnosticable {
ToggleButtonsThemeData? toggleButtonsTheme,
TooltipThemeData? tooltipTheme,
// 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(
'Use colorScheme.error instead. '
'This feature was deprecated after v3.3.0-0.5.pre.',
Expand Down Expand Up @@ -451,7 +444,6 @@ class ThemeData with Diagnosticable {
primaryColorLight ??= isDark ? Colors.grey[500]! : primarySwatch[100]!;
primaryColorDark ??= isDark ? Colors.black : primarySwatch[700]!;
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);
hoverColor ??= isDark ? Colors.white.withOpacity(0.04) : Colors.black.withOpacity(0.04);
shadowColor ??= Colors.black;
Expand Down Expand Up @@ -657,7 +649,6 @@ class ThemeData with Diagnosticable {
toggleButtonsTheme: toggleButtonsTheme,
tooltipTheme: tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
toggleableActiveColor: toggleableActiveColor,
errorColor: errorColor,
backgroundColor: backgroundColor,
);
Expand Down Expand Up @@ -766,13 +757,6 @@ class ThemeData with Diagnosticable {
required this.toggleButtonsTheme,
required this.tooltipTheme,
// 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(
'Use colorScheme.error instead. '
'This feature was deprecated after v3.3.0-0.5.pre.',
Expand All @@ -786,10 +770,8 @@ class ThemeData with Diagnosticable {

}) : // DEPRECATED (newest deprecations at the bottom)
// should not be `required`, use getter pattern to avoid breakages.
_toggleableActiveColor = toggleableActiveColor,
_errorColor = errorColor,
_backgroundColor = backgroundColor,
assert(toggleableActiveColor != null),
// DEPRECATED (newest deprecations at the bottom)
assert(errorColor != null),
assert(backgroundColor != null);
Expand Down Expand Up @@ -1469,17 +1451,6 @@ class ThemeData with Diagnosticable {
Color get backgroundColor => _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.
///
/// The [brightness] value is applied to the [colorScheme].
Expand Down Expand Up @@ -1579,13 +1550,6 @@ class ThemeData with Diagnosticable {
ToggleButtonsThemeData? toggleButtonsTheme,
TooltipThemeData? tooltipTheme,
// 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(
'Use colorScheme.error instead. '
'This feature was deprecated after v3.3.0-0.5.pre.',
Expand Down Expand Up @@ -1701,7 +1665,6 @@ class ThemeData with Diagnosticable {
toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme,
tooltipTheme: tooltipTheme ?? this.tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
toggleableActiveColor: toggleableActiveColor ?? _toggleableActiveColor,
errorColor: errorColor ?? _errorColor,
backgroundColor: backgroundColor ?? _backgroundColor,
);
Expand Down Expand Up @@ -1898,7 +1861,6 @@ class ThemeData with Diagnosticable {
toggleButtonsTheme: ToggleButtonsThemeData.lerp(a.toggleButtonsTheme, b.toggleButtonsTheme, t)!,
tooltipTheme: TooltipThemeData.lerp(a.tooltipTheme, b.tooltipTheme, t)!,
// DEPRECATED (newest deprecations at the bottom)
toggleableActiveColor: Color.lerp(a.toggleableActiveColor, b.toggleableActiveColor, t),
errorColor: Color.lerp(a.errorColor, b.errorColor, t),
backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t),
);
Expand Down Expand Up @@ -2002,7 +1964,6 @@ class ThemeData with Diagnosticable {
other.toggleButtonsTheme == toggleButtonsTheme &&
other.tooltipTheme == tooltipTheme &&
// DEPRECATED (newest deprecations at the bottom)
other.toggleableActiveColor == toggleableActiveColor &&
other.errorColor == errorColor &&
other.backgroundColor == backgroundColor;
}
Expand Down Expand Up @@ -2104,7 +2065,6 @@ class ThemeData with Diagnosticable {
toggleButtonsTheme,
tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
toggleableActiveColor,
errorColor,
backgroundColor,
];
Expand Down Expand Up @@ -2207,7 +2167,6 @@ class ThemeData with Diagnosticable {
properties.add(DiagnosticsProperty<ToggleButtonsThemeData>('toggleButtonsTheme', toggleButtonsTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<TooltipThemeData>('tooltipTheme', tooltipTheme, level: DiagnosticLevel.debug));
// 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('backgroundColor', backgroundColor, defaultValue: defaultData.backgroundColor, level: DiagnosticLevel.debug));
}
Expand Down
1 change: 0 additions & 1 deletion packages/flutter/test/material/snack_bar_test.dart
Expand Up @@ -642,7 +642,6 @@ void main() {
indicatorColor: Colors.black,
hintColor: Colors.black,
errorColor: Colors.black,
toggleableActiveColor: Colors.black,
textTheme: ThemeData.dark().textTheme,
primaryTextTheme: ThemeData.dark().textTheme,
inputDecorationTheme: ThemeData.dark().inputDecorationTheme.copyWith(border: const OutlineInputBorder()),
Expand Down
5 changes: 0 additions & 5 deletions packages/flutter/test/material/theme_data_test.dart
Expand Up @@ -902,7 +902,6 @@ void main() {
toggleButtonsTheme: const ToggleButtonsThemeData(textStyle: TextStyle(color: Colors.black)),
tooltipTheme: const TooltipThemeData(height: 100),
// DEPRECATED (newest deprecations at the bottom)
toggleableActiveColor: Colors.black,
errorColor: Colors.black,
backgroundColor: Colors.black,
);
Expand Down Expand Up @@ -1021,7 +1020,6 @@ void main() {
tooltipTheme: const TooltipThemeData(height: 100),

// DEPRECATED (newest deprecations at the bottom)
toggleableActiveColor: Colors.white,
errorColor: Colors.white,
backgroundColor: Colors.white,
);
Expand Down Expand Up @@ -1121,7 +1119,6 @@ void main() {
tooltipTheme: otherTheme.tooltipTheme,

// DEPRECATED (newest deprecations at the bottom)
toggleableActiveColor: otherTheme.toggleableActiveColor,
errorColor: otherTheme.errorColor,
backgroundColor: otherTheme.backgroundColor,
);
Expand Down Expand Up @@ -1222,7 +1219,6 @@ void main() {
expect(themeDataCopy.tooltipTheme, equals(otherTheme.tooltipTheme));

// DEPRECATED (newest deprecations at the bottom)
expect(themeDataCopy.toggleableActiveColor, equals(otherTheme.toggleableActiveColor));
expect(themeDataCopy.errorColor, equals(otherTheme.errorColor));
expect(themeDataCopy.backgroundColor, equals(otherTheme.backgroundColor));
});
Expand Down Expand Up @@ -1354,7 +1350,6 @@ void main() {
'toggleButtonsTheme',
'tooltipTheme',
// DEPRECATED (newest deprecations at the bottom)
'toggleableActiveColor',
'errorColor',
'backgroundColor',
};
Expand Down