Unverified Commit f38c5ad4 authored by Qun Cheng's avatar Qun Cheng Committed by GitHub

Remove deprecated `errorColor` from `ThemeData` (#144078)

This PR is to remove deprecated `ThemeData.errorColor`.

These parameters are made obsolete in https://github.com/flutter/flutter/pull/110162.
Part of https://github.com/flutter/flutter/issues/143956
parent cc33f44e
...@@ -366,12 +366,6 @@ class ThemeData with Diagnosticable { ...@@ -366,12 +366,6 @@ class ThemeData with Diagnosticable {
TimePickerThemeData? timePickerTheme, TimePickerThemeData? timePickerTheme,
ToggleButtonsThemeData? toggleButtonsTheme, ToggleButtonsThemeData? toggleButtonsTheme,
TooltipThemeData? tooltipTheme, TooltipThemeData? tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
@Deprecated(
'Use colorScheme.error instead. '
'This feature was deprecated after v3.3.0-0.5.pre.',
)
Color? errorColor,
}) { }) {
// GENERAL CONFIGURATION // GENERAL CONFIGURATION
cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault(); cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
...@@ -428,7 +422,6 @@ class ThemeData with Diagnosticable { ...@@ -428,7 +422,6 @@ class ThemeData with Diagnosticable {
dividerColor ??= colorScheme.outline; dividerColor ??= colorScheme.outline;
dialogBackgroundColor ??= colorScheme.background; dialogBackgroundColor ??= colorScheme.background;
indicatorColor ??= onPrimarySurfaceColor; indicatorColor ??= onPrimarySurfaceColor;
errorColor ??= colorScheme.error;
applyElevationOverlayColor ??= brightness == Brightness.dark; applyElevationOverlayColor ??= brightness == Brightness.dark;
} }
applyElevationOverlayColor ??= false; applyElevationOverlayColor ??= false;
...@@ -545,9 +538,6 @@ class ThemeData with Diagnosticable { ...@@ -545,9 +538,6 @@ class ThemeData with Diagnosticable {
timePickerTheme ??= const TimePickerThemeData(); timePickerTheme ??= const TimePickerThemeData();
toggleButtonsTheme ??= const ToggleButtonsThemeData(); toggleButtonsTheme ??= const ToggleButtonsThemeData();
tooltipTheme ??= const TooltipThemeData(); tooltipTheme ??= const TooltipThemeData();
// DEPRECATED (newest deprecations at the bottom)
errorColor ??= Colors.red[700]!;
return ThemeData.raw( return ThemeData.raw(
// For the sanity of the reader, make sure these properties are in the same // For the sanity of the reader, make sure these properties are in the same
// order in every place that they are separated by section comments (e.g. // order in every place that they are separated by section comments (e.g.
...@@ -640,8 +630,6 @@ class ThemeData with Diagnosticable { ...@@ -640,8 +630,6 @@ class ThemeData with Diagnosticable {
timePickerTheme: timePickerTheme, timePickerTheme: timePickerTheme,
toggleButtonsTheme: toggleButtonsTheme, toggleButtonsTheme: toggleButtonsTheme,
tooltipTheme: tooltipTheme, tooltipTheme: tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
errorColor: errorColor,
); );
} }
...@@ -747,18 +735,7 @@ class ThemeData with Diagnosticable { ...@@ -747,18 +735,7 @@ class ThemeData with Diagnosticable {
required this.timePickerTheme, required this.timePickerTheme,
required this.toggleButtonsTheme, required this.toggleButtonsTheme,
required this.tooltipTheme, required this.tooltipTheme,
// DEPRECATED (newest deprecations at the bottom) });
@Deprecated(
'Use colorScheme.error instead. '
'This feature was deprecated after v3.3.0-0.5.pre.',
)
Color? errorColor,
}) : // DEPRECATED (newest deprecations at the bottom)
// should not be `required`, use getter pattern to avoid breakages.
_errorColor = errorColor,
// DEPRECATED (newest deprecations at the bottom)
assert(errorColor != null);
/// Create a [ThemeData] based on the colors in the given [colorScheme] and /// Create a [ThemeData] based on the colors in the given [colorScheme] and
/// text styles of the optional [textTheme]. /// text styles of the optional [textTheme].
...@@ -807,7 +784,6 @@ class ThemeData with Diagnosticable { ...@@ -807,7 +784,6 @@ class ThemeData with Diagnosticable {
dividerColor: colorScheme.onSurface.withOpacity(0.12), dividerColor: colorScheme.onSurface.withOpacity(0.12),
dialogBackgroundColor: colorScheme.background, dialogBackgroundColor: colorScheme.background,
indicatorColor: onPrimarySurfaceColor, indicatorColor: onPrimarySurfaceColor,
errorColor: colorScheme.error,
textTheme: textTheme, textTheme: textTheme,
applyElevationOverlayColor: isDark, applyElevationOverlayColor: isDark,
useMaterial3: useMaterial3, useMaterial3: useMaterial3,
...@@ -1414,17 +1390,6 @@ class ThemeData with Diagnosticable { ...@@ -1414,17 +1390,6 @@ class ThemeData with Diagnosticable {
/// This is the value returned from [TooltipTheme.of]. /// This is the value returned from [TooltipTheme.of].
final TooltipThemeData tooltipTheme; final TooltipThemeData tooltipTheme;
// DEPRECATED (newest deprecations at the bottom)
/// Obsolete property that was used for input validation errors, e.g. in
/// [TextField] fields. Use [ColorScheme.error] instead.
@Deprecated(
'Use colorScheme.error instead. '
'This feature was deprecated after v3.3.0-0.5.pre.',
)
Color get errorColor => _errorColor!;
final Color? _errorColor;
/// 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].
...@@ -1524,11 +1489,6 @@ class ThemeData with Diagnosticable { ...@@ -1524,11 +1489,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(
'Use colorScheme.error instead. '
'This feature was deprecated after v3.3.0-0.5.pre.',
)
Color? errorColor,
@Deprecated( @Deprecated(
'Use a ThemeData constructor (.from, .light, or .dark) instead. ' 'Use a ThemeData constructor (.from, .light, or .dark) instead. '
'These constructors all have a useMaterial3 argument, ' 'These constructors all have a useMaterial3 argument, '
...@@ -1633,8 +1593,6 @@ class ThemeData with Diagnosticable { ...@@ -1633,8 +1593,6 @@ class ThemeData with Diagnosticable {
timePickerTheme: timePickerTheme ?? this.timePickerTheme, timePickerTheme: timePickerTheme ?? this.timePickerTheme,
toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme, toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme,
tooltipTheme: tooltipTheme ?? this.tooltipTheme, tooltipTheme: tooltipTheme ?? this.tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
errorColor: errorColor ?? _errorColor,
); );
} }
...@@ -1828,8 +1786,6 @@ class ThemeData with Diagnosticable { ...@@ -1828,8 +1786,6 @@ class ThemeData with Diagnosticable {
timePickerTheme: TimePickerThemeData.lerp(a.timePickerTheme, b.timePickerTheme, t), timePickerTheme: TimePickerThemeData.lerp(a.timePickerTheme, b.timePickerTheme, t),
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)
errorColor: Color.lerp(a.errorColor, b.errorColor, t),
); );
} }
...@@ -1929,9 +1885,7 @@ class ThemeData with Diagnosticable { ...@@ -1929,9 +1885,7 @@ class ThemeData with Diagnosticable {
other.textSelectionTheme == textSelectionTheme && other.textSelectionTheme == textSelectionTheme &&
other.timePickerTheme == timePickerTheme && other.timePickerTheme == timePickerTheme &&
other.toggleButtonsTheme == toggleButtonsTheme && other.toggleButtonsTheme == toggleButtonsTheme &&
other.tooltipTheme == tooltipTheme && other.tooltipTheme == tooltipTheme;
// DEPRECATED (newest deprecations at the bottom)
other.errorColor == errorColor;
} }
@override @override
...@@ -2030,8 +1984,6 @@ class ThemeData with Diagnosticable { ...@@ -2030,8 +1984,6 @@ class ThemeData with Diagnosticable {
timePickerTheme, timePickerTheme,
toggleButtonsTheme, toggleButtonsTheme,
tooltipTheme, tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
errorColor,
]; ];
return Object.hashAll(values); return Object.hashAll(values);
} }
...@@ -2131,8 +2083,6 @@ class ThemeData with Diagnosticable { ...@@ -2131,8 +2083,6 @@ class ThemeData with Diagnosticable {
properties.add(DiagnosticsProperty<TimePickerThemeData>('timePickerTheme', timePickerTheme, defaultValue: defaultData.timePickerTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<TimePickerThemeData>('timePickerTheme', timePickerTheme, defaultValue: defaultData.timePickerTheme, level: DiagnosticLevel.debug));
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)
properties.add(ColorProperty('errorColor', errorColor, defaultValue: defaultData.errorColor, level: DiagnosticLevel.debug));
} }
} }
......
...@@ -640,7 +640,6 @@ void main() { ...@@ -640,7 +640,6 @@ void main() {
dialogBackgroundColor: Colors.black, dialogBackgroundColor: Colors.black,
indicatorColor: Colors.black, indicatorColor: Colors.black,
hintColor: Colors.black, hintColor: Colors.black,
errorColor: 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()),
......
...@@ -196,7 +196,6 @@ void main() { ...@@ -196,7 +196,6 @@ void main() {
expect(theme.dividerColor, theme.colorScheme.outline); expect(theme.dividerColor, theme.colorScheme.outline);
expect(theme.dialogBackgroundColor, theme.colorScheme.background); expect(theme.dialogBackgroundColor, theme.colorScheme.background);
expect(theme.indicatorColor, theme.colorScheme.onPrimary); expect(theme.indicatorColor, theme.colorScheme.onPrimary);
expect(theme.errorColor, theme.colorScheme.error);
expect(theme.applyElevationOverlayColor, false); expect(theme.applyElevationOverlayColor, false);
}); });
...@@ -264,7 +263,6 @@ void main() { ...@@ -264,7 +263,6 @@ void main() {
expect(theme.dividerColor, theme.colorScheme.outline); expect(theme.dividerColor, theme.colorScheme.outline);
expect(theme.dialogBackgroundColor, theme.colorScheme.background); expect(theme.dialogBackgroundColor, theme.colorScheme.background);
expect(theme.indicatorColor, theme.colorScheme.onSurface); expect(theme.indicatorColor, theme.colorScheme.onSurface);
expect(theme.errorColor, theme.colorScheme.error);
expect(theme.applyElevationOverlayColor, true); expect(theme.applyElevationOverlayColor, true);
}); });
...@@ -327,7 +325,6 @@ void main() { ...@@ -327,7 +325,6 @@ void main() {
expect(theme.dividerColor, theme.colorScheme.outline); expect(theme.dividerColor, theme.colorScheme.outline);
expect(theme.dialogBackgroundColor, theme.colorScheme.background); expect(theme.dialogBackgroundColor, theme.colorScheme.background);
expect(theme.indicatorColor, theme.colorScheme.onPrimary); expect(theme.indicatorColor, theme.colorScheme.onPrimary);
expect(theme.errorColor, theme.colorScheme.error);
expect(theme.applyElevationOverlayColor, false); expect(theme.applyElevationOverlayColor, false);
}); });
...@@ -391,7 +388,6 @@ void main() { ...@@ -391,7 +388,6 @@ void main() {
expect(theme.dividerColor, theme.colorScheme.outline); expect(theme.dividerColor, theme.colorScheme.outline);
expect(theme.dialogBackgroundColor, theme.colorScheme.background); expect(theme.dialogBackgroundColor, theme.colorScheme.background);
expect(theme.indicatorColor, theme.colorScheme.onPrimary); expect(theme.indicatorColor, theme.colorScheme.onPrimary);
expect(theme.errorColor, theme.colorScheme.error);
expect(theme.applyElevationOverlayColor, false); expect(theme.applyElevationOverlayColor, false);
}); });
...@@ -454,7 +450,6 @@ void main() { ...@@ -454,7 +450,6 @@ void main() {
expect(theme.dividerColor, theme.colorScheme.outline); expect(theme.dividerColor, theme.colorScheme.outline);
expect(theme.dialogBackgroundColor, theme.colorScheme.background); expect(theme.dialogBackgroundColor, theme.colorScheme.background);
expect(theme.indicatorColor, theme.colorScheme.onSurface); expect(theme.indicatorColor, theme.colorScheme.onSurface);
expect(theme.errorColor, theme.colorScheme.error);
expect(theme.applyElevationOverlayColor, true); expect(theme.applyElevationOverlayColor, true);
}); });
...@@ -468,7 +463,6 @@ void main() { ...@@ -468,7 +463,6 @@ void main() {
expect(theme.canvasColor, equals(lightColors.background)); expect(theme.canvasColor, equals(lightColors.background));
expect(theme.scaffoldBackgroundColor, equals(lightColors.background)); expect(theme.scaffoldBackgroundColor, equals(lightColors.background));
expect(theme.dialogBackgroundColor, equals(lightColors.background)); expect(theme.dialogBackgroundColor, equals(lightColors.background));
expect(theme.errorColor, equals(lightColors.error));
expect(theme.applyElevationOverlayColor, isFalse); expect(theme.applyElevationOverlayColor, isFalse);
}); });
...@@ -483,7 +477,6 @@ void main() { ...@@ -483,7 +477,6 @@ void main() {
expect(theme.canvasColor, equals(darkColors.background)); expect(theme.canvasColor, equals(darkColors.background));
expect(theme.scaffoldBackgroundColor, equals(darkColors.background)); expect(theme.scaffoldBackgroundColor, equals(darkColors.background));
expect(theme.dialogBackgroundColor, equals(darkColors.background)); expect(theme.dialogBackgroundColor, equals(darkColors.background));
expect(theme.errorColor, equals(darkColors.error));
expect(theme.applyElevationOverlayColor, isTrue); expect(theme.applyElevationOverlayColor, isTrue);
}); });
...@@ -894,8 +887,6 @@ void main() { ...@@ -894,8 +887,6 @@ void main() {
timePickerTheme: const TimePickerThemeData(backgroundColor: Colors.black), timePickerTheme: const TimePickerThemeData(backgroundColor: Colors.black),
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)
errorColor: Colors.black,
); );
final SliderThemeData otherSliderTheme = SliderThemeData.fromPrimaryColors( final SliderThemeData otherSliderTheme = SliderThemeData.fromPrimaryColors(
...@@ -1010,9 +1001,6 @@ void main() { ...@@ -1010,9 +1001,6 @@ void main() {
timePickerTheme: const TimePickerThemeData(backgroundColor: Colors.white), timePickerTheme: const TimePickerThemeData(backgroundColor: Colors.white),
toggleButtonsTheme: const ToggleButtonsThemeData(textStyle: TextStyle(color: Colors.white)), toggleButtonsTheme: const ToggleButtonsThemeData(textStyle: TextStyle(color: Colors.white)),
tooltipTheme: const TooltipThemeData(height: 100), tooltipTheme: const TooltipThemeData(height: 100),
// DEPRECATED (newest deprecations at the bottom)
errorColor: Colors.white,
); );
final ThemeData themeDataCopy = theme.copyWith( final ThemeData themeDataCopy = theme.copyWith(
...@@ -1108,9 +1096,6 @@ void main() { ...@@ -1108,9 +1096,6 @@ void main() {
timePickerTheme: otherTheme.timePickerTheme, timePickerTheme: otherTheme.timePickerTheme,
toggleButtonsTheme: otherTheme.toggleButtonsTheme, toggleButtonsTheme: otherTheme.toggleButtonsTheme,
tooltipTheme: otherTheme.tooltipTheme, tooltipTheme: otherTheme.tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
errorColor: otherTheme.errorColor,
); );
// For the sanity of the reader, make sure these properties are in the same // For the sanity of the reader, make sure these properties are in the same
...@@ -1207,9 +1192,6 @@ void main() { ...@@ -1207,9 +1192,6 @@ void main() {
expect(themeDataCopy.timePickerTheme, equals(otherTheme.timePickerTheme)); expect(themeDataCopy.timePickerTheme, equals(otherTheme.timePickerTheme));
expect(themeDataCopy.toggleButtonsTheme, equals(otherTheme.toggleButtonsTheme)); expect(themeDataCopy.toggleButtonsTheme, equals(otherTheme.toggleButtonsTheme));
expect(themeDataCopy.tooltipTheme, equals(otherTheme.tooltipTheme)); expect(themeDataCopy.tooltipTheme, equals(otherTheme.tooltipTheme));
// DEPRECATED (newest deprecations at the bottom)
expect(themeDataCopy.errorColor, equals(otherTheme.errorColor));
}); });
testWidgets('ThemeData.toString has less than 200 characters output', (WidgetTester tester) async { testWidgets('ThemeData.toString has less than 200 characters output', (WidgetTester tester) async {
...@@ -1244,7 +1226,6 @@ void main() { ...@@ -1244,7 +1226,6 @@ void main() {
expect(theme.canvasColor, equals(lightColors.background)); expect(theme.canvasColor, equals(lightColors.background));
expect(theme.scaffoldBackgroundColor, equals(lightColors.background)); expect(theme.scaffoldBackgroundColor, equals(lightColors.background));
expect(theme.dialogBackgroundColor, equals(lightColors.background)); expect(theme.dialogBackgroundColor, equals(lightColors.background));
expect(theme.errorColor, equals(lightColors.error));
expect(theme.applyElevationOverlayColor, isFalse); expect(theme.applyElevationOverlayColor, isFalse);
}); });
...@@ -1337,8 +1318,6 @@ void main() { ...@@ -1337,8 +1318,6 @@ void main() {
'timePickerTheme', 'timePickerTheme',
'toggleButtonsTheme', 'toggleButtonsTheme',
'tooltipTheme', 'tooltipTheme',
// DEPRECATED (newest deprecations at the bottom)
'errorColor',
}; };
final DiagnosticPropertiesBuilder properties = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder properties = DiagnosticPropertiesBuilder();
......
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