Skip to content

Commit ee6111a

Browse files
authored
Remove deprecated backgroundColor from ThemeData (#144079)
This PR is to remove deprecated ThemeData.backgroundColor. These parameters are made obsolete in flutter/flutter#110162. Part of flutter/flutter#143956
1 parent 6068891 commit ee6111a

File tree

3 files changed

+2
-52
lines changed

3 files changed

+2
-52
lines changed

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

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,6 @@ class ThemeData with Diagnosticable {
372372
'This feature was deprecated after v3.3.0-0.5.pre.',
373373
)
374374
Color? errorColor,
375-
@Deprecated(
376-
'Use colorScheme.background instead. '
377-
'This feature was deprecated after v3.3.0-0.5.pre.',
378-
)
379-
Color? backgroundColor,
380375
}) {
381376
// GENERAL CONFIGURATION
382377
cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
@@ -431,7 +426,6 @@ class ThemeData with Diagnosticable {
431426
scaffoldBackgroundColor ??= colorScheme.background;
432427
cardColor ??= colorScheme.surface;
433428
dividerColor ??= colorScheme.outline;
434-
backgroundColor ??= colorScheme.background;
435429
dialogBackgroundColor ??= colorScheme.background;
436430
indicatorColor ??= onPrimarySurfaceColor;
437431
errorColor ??= colorScheme.error;
@@ -554,8 +548,6 @@ class ThemeData with Diagnosticable {
554548

555549
// DEPRECATED (newest deprecations at the bottom)
556550
errorColor ??= Colors.red[700]!;
557-
backgroundColor ??= isDark ? Colors.grey[700]! : primarySwatch[200]!;
558-
559551
return ThemeData.raw(
560552
// For the sanity of the reader, make sure these properties are in the same
561553
// order in every place that they are separated by section comments (e.g.
@@ -650,7 +642,6 @@ class ThemeData with Diagnosticable {
650642
tooltipTheme: tooltipTheme,
651643
// DEPRECATED (newest deprecations at the bottom)
652644
errorColor: errorColor,
653-
backgroundColor: backgroundColor,
654645
);
655646
}
656647

@@ -762,19 +753,12 @@ class ThemeData with Diagnosticable {
762753
'This feature was deprecated after v3.3.0-0.5.pre.',
763754
)
764755
Color? errorColor,
765-
@Deprecated(
766-
'Use colorScheme.background instead. '
767-
'This feature was deprecated after v3.3.0-0.5.pre.',
768-
)
769-
Color? backgroundColor,
770756

771757
}) : // DEPRECATED (newest deprecations at the bottom)
772758
// should not be `required`, use getter pattern to avoid breakages.
773759
_errorColor = errorColor,
774-
_backgroundColor = backgroundColor,
775760
// DEPRECATED (newest deprecations at the bottom)
776-
assert(errorColor != null),
777-
assert(backgroundColor != null);
761+
assert(errorColor != null);
778762

779763
/// Create a [ThemeData] based on the colors in the given [colorScheme] and
780764
/// text styles of the optional [textTheme].
@@ -821,7 +805,6 @@ class ThemeData with Diagnosticable {
821805
scaffoldBackgroundColor: colorScheme.background,
822806
cardColor: colorScheme.surface,
823807
dividerColor: colorScheme.onSurface.withOpacity(0.12),
824-
backgroundColor: colorScheme.background,
825808
dialogBackgroundColor: colorScheme.background,
826809
indicatorColor: onPrimarySurfaceColor,
827810
errorColor: colorScheme.error,
@@ -1442,15 +1425,6 @@ class ThemeData with Diagnosticable {
14421425
Color get errorColor => _errorColor!;
14431426
final Color? _errorColor;
14441427

1445-
/// Obsolete property that was unused by the framework.
1446-
/// Use [ColorScheme.background] instead.
1447-
@Deprecated(
1448-
'Use colorScheme.background instead. '
1449-
'This feature was deprecated after v3.3.0-0.5.pre.',
1450-
)
1451-
Color get backgroundColor => _backgroundColor!;
1452-
final Color? _backgroundColor;
1453-
14541428
/// Creates a copy of this theme but with the given fields replaced with the new values.
14551429
///
14561430
/// The [brightness] value is applied to the [colorScheme].
@@ -1555,11 +1529,6 @@ class ThemeData with Diagnosticable {
15551529
'This feature was deprecated after v3.3.0-0.5.pre.',
15561530
)
15571531
Color? errorColor,
1558-
@Deprecated(
1559-
'Use colorScheme.background instead. '
1560-
'This feature was deprecated after v3.3.0-0.5.pre.',
1561-
)
1562-
Color? backgroundColor,
15631532
@Deprecated(
15641533
'Use a ThemeData constructor (.from, .light, or .dark) instead. '
15651534
'These constructors all have a useMaterial3 argument, '
@@ -1666,7 +1635,6 @@ class ThemeData with Diagnosticable {
16661635
tooltipTheme: tooltipTheme ?? this.tooltipTheme,
16671636
// DEPRECATED (newest deprecations at the bottom)
16681637
errorColor: errorColor ?? _errorColor,
1669-
backgroundColor: backgroundColor ?? _backgroundColor,
16701638
);
16711639
}
16721640

@@ -1862,7 +1830,6 @@ class ThemeData with Diagnosticable {
18621830
tooltipTheme: TooltipThemeData.lerp(a.tooltipTheme, b.tooltipTheme, t)!,
18631831
// DEPRECATED (newest deprecations at the bottom)
18641832
errorColor: Color.lerp(a.errorColor, b.errorColor, t),
1865-
backgroundColor: Color.lerp(a.backgroundColor, b.backgroundColor, t),
18661833
);
18671834
}
18681835

@@ -1964,8 +1931,7 @@ class ThemeData with Diagnosticable {
19641931
other.toggleButtonsTheme == toggleButtonsTheme &&
19651932
other.tooltipTheme == tooltipTheme &&
19661933
// DEPRECATED (newest deprecations at the bottom)
1967-
other.errorColor == errorColor &&
1968-
other.backgroundColor == backgroundColor;
1934+
other.errorColor == errorColor;
19691935
}
19701936

19711937
@override
@@ -2066,7 +2032,6 @@ class ThemeData with Diagnosticable {
20662032
tooltipTheme,
20672033
// DEPRECATED (newest deprecations at the bottom)
20682034
errorColor,
2069-
backgroundColor,
20702035
];
20712036
return Object.hashAll(values);
20722037
}
@@ -2168,7 +2133,6 @@ class ThemeData with Diagnosticable {
21682133
properties.add(DiagnosticsProperty<TooltipThemeData>('tooltipTheme', tooltipTheme, level: DiagnosticLevel.debug));
21692134
// DEPRECATED (newest deprecations at the bottom)
21702135
properties.add(ColorProperty('errorColor', errorColor, defaultValue: defaultData.errorColor, level: DiagnosticLevel.debug));
2171-
properties.add(ColorProperty('backgroundColor', backgroundColor, defaultValue: defaultData.backgroundColor, level: DiagnosticLevel.debug));
21722136
}
21732137
}
21742138

packages/flutter/test/material/snack_bar_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,6 @@ void main() {
637637
buttonTheme: const ButtonThemeData(colorScheme: ColorScheme.dark()),
638638
toggleButtonsTheme: const ToggleButtonsThemeData(textStyle: TextStyle(color: Colors.black)),
639639
secondaryHeaderColor: Colors.black,
640-
backgroundColor: Colors.black,
641640
dialogBackgroundColor: Colors.black,
642641
indicatorColor: Colors.black,
643642
hintColor: Colors.black,

packages/flutter/test/material/theme_data_test.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ void main() {
194194
expect(theme.scaffoldBackgroundColor, theme.colorScheme.background);
195195
expect(theme.cardColor, theme.colorScheme.surface);
196196
expect(theme.dividerColor, theme.colorScheme.outline);
197-
expect(theme.backgroundColor, theme.colorScheme.background);
198197
expect(theme.dialogBackgroundColor, theme.colorScheme.background);
199198
expect(theme.indicatorColor, theme.colorScheme.onPrimary);
200199
expect(theme.errorColor, theme.colorScheme.error);
@@ -263,7 +262,6 @@ void main() {
263262
expect(theme.scaffoldBackgroundColor, theme.colorScheme.background);
264263
expect(theme.cardColor, theme.colorScheme.surface);
265264
expect(theme.dividerColor, theme.colorScheme.outline);
266-
expect(theme.backgroundColor, theme.colorScheme.background);
267265
expect(theme.dialogBackgroundColor, theme.colorScheme.background);
268266
expect(theme.indicatorColor, theme.colorScheme.onSurface);
269267
expect(theme.errorColor, theme.colorScheme.error);
@@ -327,7 +325,6 @@ void main() {
327325
expect(theme.scaffoldBackgroundColor, theme.colorScheme.background);
328326
expect(theme.cardColor, theme.colorScheme.surface);
329327
expect(theme.dividerColor, theme.colorScheme.outline);
330-
expect(theme.backgroundColor, theme.colorScheme.background);
331328
expect(theme.dialogBackgroundColor, theme.colorScheme.background);
332329
expect(theme.indicatorColor, theme.colorScheme.onPrimary);
333330
expect(theme.errorColor, theme.colorScheme.error);
@@ -392,7 +389,6 @@ void main() {
392389
expect(theme.scaffoldBackgroundColor, theme.colorScheme.background);
393390
expect(theme.cardColor, theme.colorScheme.surface);
394391
expect(theme.dividerColor, theme.colorScheme.outline);
395-
expect(theme.backgroundColor, theme.colorScheme.background);
396392
expect(theme.dialogBackgroundColor, theme.colorScheme.background);
397393
expect(theme.indicatorColor, theme.colorScheme.onPrimary);
398394
expect(theme.errorColor, theme.colorScheme.error);
@@ -456,7 +452,6 @@ void main() {
456452
expect(theme.scaffoldBackgroundColor, theme.colorScheme.background);
457453
expect(theme.cardColor, theme.colorScheme.surface);
458454
expect(theme.dividerColor, theme.colorScheme.outline);
459-
expect(theme.backgroundColor, theme.colorScheme.background);
460455
expect(theme.dialogBackgroundColor, theme.colorScheme.background);
461456
expect(theme.indicatorColor, theme.colorScheme.onSurface);
462457
expect(theme.errorColor, theme.colorScheme.error);
@@ -470,7 +465,6 @@ void main() {
470465
expect(theme.brightness, equals(Brightness.light));
471466
expect(theme.primaryColor, equals(lightColors.primary));
472467
expect(theme.cardColor, equals(lightColors.surface));
473-
expect(theme.backgroundColor, equals(lightColors.background));
474468
expect(theme.canvasColor, equals(lightColors.background));
475469
expect(theme.scaffoldBackgroundColor, equals(lightColors.background));
476470
expect(theme.dialogBackgroundColor, equals(lightColors.background));
@@ -486,7 +480,6 @@ void main() {
486480
// in dark theme's the color used for main components is surface instead of primary
487481
expect(theme.primaryColor, equals(darkColors.surface));
488482
expect(theme.cardColor, equals(darkColors.surface));
489-
expect(theme.backgroundColor, equals(darkColors.background));
490483
expect(theme.canvasColor, equals(darkColors.background));
491484
expect(theme.scaffoldBackgroundColor, equals(darkColors.background));
492485
expect(theme.dialogBackgroundColor, equals(darkColors.background));
@@ -903,7 +896,6 @@ void main() {
903896
tooltipTheme: const TooltipThemeData(height: 100),
904897
// DEPRECATED (newest deprecations at the bottom)
905898
errorColor: Colors.black,
906-
backgroundColor: Colors.black,
907899
);
908900

909901
final SliderThemeData otherSliderTheme = SliderThemeData.fromPrimaryColors(
@@ -1021,7 +1013,6 @@ void main() {
10211013

10221014
// DEPRECATED (newest deprecations at the bottom)
10231015
errorColor: Colors.white,
1024-
backgroundColor: Colors.white,
10251016
);
10261017

10271018
final ThemeData themeDataCopy = theme.copyWith(
@@ -1120,7 +1111,6 @@ void main() {
11201111

11211112
// DEPRECATED (newest deprecations at the bottom)
11221113
errorColor: otherTheme.errorColor,
1123-
backgroundColor: otherTheme.backgroundColor,
11241114
);
11251115

11261116
// For the sanity of the reader, make sure these properties are in the same
@@ -1220,7 +1210,6 @@ void main() {
12201210

12211211
// DEPRECATED (newest deprecations at the bottom)
12221212
expect(themeDataCopy.errorColor, equals(otherTheme.errorColor));
1223-
expect(themeDataCopy.backgroundColor, equals(otherTheme.backgroundColor));
12241213
});
12251214

12261215
testWidgets('ThemeData.toString has less than 200 characters output', (WidgetTester tester) async {
@@ -1252,7 +1241,6 @@ void main() {
12521241
expect(theme.colorScheme.brightness, equals(Brightness.dark));
12531242
expect(theme.primaryColor, equals(lightColors.primary));
12541243
expect(theme.cardColor, equals(lightColors.surface));
1255-
expect(theme.backgroundColor, equals(lightColors.background));
12561244
expect(theme.canvasColor, equals(lightColors.background));
12571245
expect(theme.scaffoldBackgroundColor, equals(lightColors.background));
12581246
expect(theme.dialogBackgroundColor, equals(lightColors.background));
@@ -1351,7 +1339,6 @@ void main() {
13511339
'tooltipTheme',
13521340
// DEPRECATED (newest deprecations at the bottom)
13531341
'errorColor',
1354-
'backgroundColor',
13551342
};
13561343

13571344
final DiagnosticPropertiesBuilder properties = DiagnosticPropertiesBuilder();

0 commit comments

Comments
 (0)