Skip to content

Commit f38c5ad

Browse files
authored
Remove deprecated errorColor from ThemeData (#144078)
This PR is to remove deprecated `ThemeData.errorColor`. These parameters are made obsolete in flutter/flutter#110162. Part of flutter/flutter#143956
1 parent cc33f44 commit f38c5ad

File tree

3 files changed

+2
-74
lines changed

3 files changed

+2
-74
lines changed

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

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,6 @@ class ThemeData with Diagnosticable {
366366
TimePickerThemeData? timePickerTheme,
367367
ToggleButtonsThemeData? toggleButtonsTheme,
368368
TooltipThemeData? tooltipTheme,
369-
// DEPRECATED (newest deprecations at the bottom)
370-
@Deprecated(
371-
'Use colorScheme.error instead. '
372-
'This feature was deprecated after v3.3.0-0.5.pre.',
373-
)
374-
Color? errorColor,
375369
}) {
376370
// GENERAL CONFIGURATION
377371
cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
@@ -428,7 +422,6 @@ class ThemeData with Diagnosticable {
428422
dividerColor ??= colorScheme.outline;
429423
dialogBackgroundColor ??= colorScheme.background;
430424
indicatorColor ??= onPrimarySurfaceColor;
431-
errorColor ??= colorScheme.error;
432425
applyElevationOverlayColor ??= brightness == Brightness.dark;
433426
}
434427
applyElevationOverlayColor ??= false;
@@ -545,9 +538,6 @@ class ThemeData with Diagnosticable {
545538
timePickerTheme ??= const TimePickerThemeData();
546539
toggleButtonsTheme ??= const ToggleButtonsThemeData();
547540
tooltipTheme ??= const TooltipThemeData();
548-
549-
// DEPRECATED (newest deprecations at the bottom)
550-
errorColor ??= Colors.red[700]!;
551541
return ThemeData.raw(
552542
// For the sanity of the reader, make sure these properties are in the same
553543
// order in every place that they are separated by section comments (e.g.
@@ -640,8 +630,6 @@ class ThemeData with Diagnosticable {
640630
timePickerTheme: timePickerTheme,
641631
toggleButtonsTheme: toggleButtonsTheme,
642632
tooltipTheme: tooltipTheme,
643-
// DEPRECATED (newest deprecations at the bottom)
644-
errorColor: errorColor,
645633
);
646634
}
647635

@@ -747,18 +735,7 @@ class ThemeData with Diagnosticable {
747735
required this.timePickerTheme,
748736
required this.toggleButtonsTheme,
749737
required this.tooltipTheme,
750-
// DEPRECATED (newest deprecations at the bottom)
751-
@Deprecated(
752-
'Use colorScheme.error instead. '
753-
'This feature was deprecated after v3.3.0-0.5.pre.',
754-
)
755-
Color? errorColor,
756-
757-
}) : // DEPRECATED (newest deprecations at the bottom)
758-
// should not be `required`, use getter pattern to avoid breakages.
759-
_errorColor = errorColor,
760-
// DEPRECATED (newest deprecations at the bottom)
761-
assert(errorColor != null);
738+
});
762739

763740
/// Create a [ThemeData] based on the colors in the given [colorScheme] and
764741
/// text styles of the optional [textTheme].
@@ -807,7 +784,6 @@ class ThemeData with Diagnosticable {
807784
dividerColor: colorScheme.onSurface.withOpacity(0.12),
808785
dialogBackgroundColor: colorScheme.background,
809786
indicatorColor: onPrimarySurfaceColor,
810-
errorColor: colorScheme.error,
811787
textTheme: textTheme,
812788
applyElevationOverlayColor: isDark,
813789
useMaterial3: useMaterial3,
@@ -1414,17 +1390,6 @@ class ThemeData with Diagnosticable {
14141390
/// This is the value returned from [TooltipTheme.of].
14151391
final TooltipThemeData tooltipTheme;
14161392

1417-
// DEPRECATED (newest deprecations at the bottom)
1418-
1419-
/// Obsolete property that was used for input validation errors, e.g. in
1420-
/// [TextField] fields. Use [ColorScheme.error] instead.
1421-
@Deprecated(
1422-
'Use colorScheme.error instead. '
1423-
'This feature was deprecated after v3.3.0-0.5.pre.',
1424-
)
1425-
Color get errorColor => _errorColor!;
1426-
final Color? _errorColor;
1427-
14281393
/// Creates a copy of this theme but with the given fields replaced with the new values.
14291394
///
14301395
/// The [brightness] value is applied to the [colorScheme].
@@ -1524,11 +1489,6 @@ class ThemeData with Diagnosticable {
15241489
ToggleButtonsThemeData? toggleButtonsTheme,
15251490
TooltipThemeData? tooltipTheme,
15261491
// DEPRECATED (newest deprecations at the bottom)
1527-
@Deprecated(
1528-
'Use colorScheme.error instead. '
1529-
'This feature was deprecated after v3.3.0-0.5.pre.',
1530-
)
1531-
Color? errorColor,
15321492
@Deprecated(
15331493
'Use a ThemeData constructor (.from, .light, or .dark) instead. '
15341494
'These constructors all have a useMaterial3 argument, '
@@ -1633,8 +1593,6 @@ class ThemeData with Diagnosticable {
16331593
timePickerTheme: timePickerTheme ?? this.timePickerTheme,
16341594
toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme,
16351595
tooltipTheme: tooltipTheme ?? this.tooltipTheme,
1636-
// DEPRECATED (newest deprecations at the bottom)
1637-
errorColor: errorColor ?? _errorColor,
16381596
);
16391597
}
16401598

@@ -1828,8 +1786,6 @@ class ThemeData with Diagnosticable {
18281786
timePickerTheme: TimePickerThemeData.lerp(a.timePickerTheme, b.timePickerTheme, t),
18291787
toggleButtonsTheme: ToggleButtonsThemeData.lerp(a.toggleButtonsTheme, b.toggleButtonsTheme, t)!,
18301788
tooltipTheme: TooltipThemeData.lerp(a.tooltipTheme, b.tooltipTheme, t)!,
1831-
// DEPRECATED (newest deprecations at the bottom)
1832-
errorColor: Color.lerp(a.errorColor, b.errorColor, t),
18331789
);
18341790
}
18351791

@@ -1929,9 +1885,7 @@ class ThemeData with Diagnosticable {
19291885
other.textSelectionTheme == textSelectionTheme &&
19301886
other.timePickerTheme == timePickerTheme &&
19311887
other.toggleButtonsTheme == toggleButtonsTheme &&
1932-
other.tooltipTheme == tooltipTheme &&
1933-
// DEPRECATED (newest deprecations at the bottom)
1934-
other.errorColor == errorColor;
1888+
other.tooltipTheme == tooltipTheme;
19351889
}
19361890

19371891
@override
@@ -2030,8 +1984,6 @@ class ThemeData with Diagnosticable {
20301984
timePickerTheme,
20311985
toggleButtonsTheme,
20321986
tooltipTheme,
2033-
// DEPRECATED (newest deprecations at the bottom)
2034-
errorColor,
20351987
];
20361988
return Object.hashAll(values);
20371989
}
@@ -2131,8 +2083,6 @@ class ThemeData with Diagnosticable {
21312083
properties.add(DiagnosticsProperty<TimePickerThemeData>('timePickerTheme', timePickerTheme, defaultValue: defaultData.timePickerTheme, level: DiagnosticLevel.debug));
21322084
properties.add(DiagnosticsProperty<ToggleButtonsThemeData>('toggleButtonsTheme', toggleButtonsTheme, level: DiagnosticLevel.debug));
21332085
properties.add(DiagnosticsProperty<TooltipThemeData>('tooltipTheme', tooltipTheme, level: DiagnosticLevel.debug));
2134-
// DEPRECATED (newest deprecations at the bottom)
2135-
properties.add(ColorProperty('errorColor', errorColor, defaultValue: defaultData.errorColor, level: DiagnosticLevel.debug));
21362086
}
21372087
}
21382088

packages/flutter/test/material/snack_bar_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,6 @@ void main() {
640640
dialogBackgroundColor: Colors.black,
641641
indicatorColor: Colors.black,
642642
hintColor: Colors.black,
643-
errorColor: Colors.black,
644643
textTheme: ThemeData.dark().textTheme,
645644
primaryTextTheme: ThemeData.dark().textTheme,
646645
inputDecorationTheme: ThemeData.dark().inputDecorationTheme.copyWith(border: const OutlineInputBorder()),

packages/flutter/test/material/theme_data_test.dart

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ void main() {
196196
expect(theme.dividerColor, theme.colorScheme.outline);
197197
expect(theme.dialogBackgroundColor, theme.colorScheme.background);
198198
expect(theme.indicatorColor, theme.colorScheme.onPrimary);
199-
expect(theme.errorColor, theme.colorScheme.error);
200199
expect(theme.applyElevationOverlayColor, false);
201200
});
202201

@@ -264,7 +263,6 @@ void main() {
264263
expect(theme.dividerColor, theme.colorScheme.outline);
265264
expect(theme.dialogBackgroundColor, theme.colorScheme.background);
266265
expect(theme.indicatorColor, theme.colorScheme.onSurface);
267-
expect(theme.errorColor, theme.colorScheme.error);
268266
expect(theme.applyElevationOverlayColor, true);
269267
});
270268

@@ -327,7 +325,6 @@ void main() {
327325
expect(theme.dividerColor, theme.colorScheme.outline);
328326
expect(theme.dialogBackgroundColor, theme.colorScheme.background);
329327
expect(theme.indicatorColor, theme.colorScheme.onPrimary);
330-
expect(theme.errorColor, theme.colorScheme.error);
331328
expect(theme.applyElevationOverlayColor, false);
332329
});
333330

@@ -391,7 +388,6 @@ void main() {
391388
expect(theme.dividerColor, theme.colorScheme.outline);
392389
expect(theme.dialogBackgroundColor, theme.colorScheme.background);
393390
expect(theme.indicatorColor, theme.colorScheme.onPrimary);
394-
expect(theme.errorColor, theme.colorScheme.error);
395391
expect(theme.applyElevationOverlayColor, false);
396392
});
397393

@@ -454,7 +450,6 @@ void main() {
454450
expect(theme.dividerColor, theme.colorScheme.outline);
455451
expect(theme.dialogBackgroundColor, theme.colorScheme.background);
456452
expect(theme.indicatorColor, theme.colorScheme.onSurface);
457-
expect(theme.errorColor, theme.colorScheme.error);
458453
expect(theme.applyElevationOverlayColor, true);
459454
});
460455

@@ -468,7 +463,6 @@ void main() {
468463
expect(theme.canvasColor, equals(lightColors.background));
469464
expect(theme.scaffoldBackgroundColor, equals(lightColors.background));
470465
expect(theme.dialogBackgroundColor, equals(lightColors.background));
471-
expect(theme.errorColor, equals(lightColors.error));
472466
expect(theme.applyElevationOverlayColor, isFalse);
473467
});
474468

@@ -483,7 +477,6 @@ void main() {
483477
expect(theme.canvasColor, equals(darkColors.background));
484478
expect(theme.scaffoldBackgroundColor, equals(darkColors.background));
485479
expect(theme.dialogBackgroundColor, equals(darkColors.background));
486-
expect(theme.errorColor, equals(darkColors.error));
487480
expect(theme.applyElevationOverlayColor, isTrue);
488481
});
489482

@@ -894,8 +887,6 @@ void main() {
894887
timePickerTheme: const TimePickerThemeData(backgroundColor: Colors.black),
895888
toggleButtonsTheme: const ToggleButtonsThemeData(textStyle: TextStyle(color: Colors.black)),
896889
tooltipTheme: const TooltipThemeData(height: 100),
897-
// DEPRECATED (newest deprecations at the bottom)
898-
errorColor: Colors.black,
899890
);
900891

901892
final SliderThemeData otherSliderTheme = SliderThemeData.fromPrimaryColors(
@@ -1010,9 +1001,6 @@ void main() {
10101001
timePickerTheme: const TimePickerThemeData(backgroundColor: Colors.white),
10111002
toggleButtonsTheme: const ToggleButtonsThemeData(textStyle: TextStyle(color: Colors.white)),
10121003
tooltipTheme: const TooltipThemeData(height: 100),
1013-
1014-
// DEPRECATED (newest deprecations at the bottom)
1015-
errorColor: Colors.white,
10161004
);
10171005

10181006
final ThemeData themeDataCopy = theme.copyWith(
@@ -1108,9 +1096,6 @@ void main() {
11081096
timePickerTheme: otherTheme.timePickerTheme,
11091097
toggleButtonsTheme: otherTheme.toggleButtonsTheme,
11101098
tooltipTheme: otherTheme.tooltipTheme,
1111-
1112-
// DEPRECATED (newest deprecations at the bottom)
1113-
errorColor: otherTheme.errorColor,
11141099
);
11151100

11161101
// For the sanity of the reader, make sure these properties are in the same
@@ -1207,9 +1192,6 @@ void main() {
12071192
expect(themeDataCopy.timePickerTheme, equals(otherTheme.timePickerTheme));
12081193
expect(themeDataCopy.toggleButtonsTheme, equals(otherTheme.toggleButtonsTheme));
12091194
expect(themeDataCopy.tooltipTheme, equals(otherTheme.tooltipTheme));
1210-
1211-
// DEPRECATED (newest deprecations at the bottom)
1212-
expect(themeDataCopy.errorColor, equals(otherTheme.errorColor));
12131195
});
12141196

12151197
testWidgets('ThemeData.toString has less than 200 characters output', (WidgetTester tester) async {
@@ -1244,7 +1226,6 @@ void main() {
12441226
expect(theme.canvasColor, equals(lightColors.background));
12451227
expect(theme.scaffoldBackgroundColor, equals(lightColors.background));
12461228
expect(theme.dialogBackgroundColor, equals(lightColors.background));
1247-
expect(theme.errorColor, equals(lightColors.error));
12481229
expect(theme.applyElevationOverlayColor, isFalse);
12491230
});
12501231

@@ -1337,8 +1318,6 @@ void main() {
13371318
'timePickerTheme',
13381319
'toggleButtonsTheme',
13391320
'tooltipTheme',
1340-
// DEPRECATED (newest deprecations at the bottom)
1341-
'errorColor',
13421321
};
13431322

13441323
final DiagnosticPropertiesBuilder properties = DiagnosticPropertiesBuilder();

0 commit comments

Comments
 (0)