Deprecate ThemeData.indicatorColor in favor of TabBarThemeData.indicatorColor (#160024)

Related to [☂️ Material Theme System
Updates](https://github.com/flutter/flutter/issues/91772)

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
Taha Tesser 2025-01-22 15:45:20 +02:00 committed by GitHub
parent b4a81cb6da
commit 9adbc51a80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 152 additions and 58 deletions

View File

@ -26,6 +26,68 @@
# * WidgetState: fix_widget_state.yaml # * WidgetState: fix_widget_state.yaml
version: 1 version: 1
transforms: transforms:
# Changes made in https://github.com/flutter/flutter/pull/160024
- title: "Migrate 'ThemeData.indicatorColor' to 'TabBarThemeData.indicatorColor'"
date: 2025-01-03
element:
uris: [ 'material.dart' ]
method: 'copyWith'
inClass: 'ThemeData'
oneOf:
- if: "indicatorColor != '' && tabBarTheme != ''"
changes:
- kind: 'removeParameter'
name: 'indicatorColor'
- if: "indicatorColor != '' && tabBarTheme == ''"
changes:
- kind: 'removeParameter'
name: 'indicatorColor'
- kind: 'addParameter'
index: 136
name: 'tabBarTheme'
style: optional_named
argumentValue:
expression: 'TabBarThemeData(indicatorColor: {% indicatorColor %})'
requiredIf: "indicatorColor != ''"
variables:
indicatorColor:
kind: 'fragment'
value: 'arguments[indicatorColor]'
tabBarTheme:
kind: 'fragment'
value: 'arguments[tabBarTheme]'
# Changes made in https://github.com/flutter/flutter/pull/160024
- title: "Migrate 'ThemeData.indicatorColor' to 'TabBarThemeData.indicatorColor'"
date: 2025-01-03
element:
uris: [ 'material.dart' ]
constructor: ''
inClass: 'ThemeData'
oneOf:
- if: "indicatorColor != '' && tabBarTheme != ''"
changes:
- kind: 'removeParameter'
name: 'indicatorColor'
- if: "indicatorColor != '' && tabBarTheme == ''"
changes:
- kind: 'removeParameter'
name: 'indicatorColor'
- kind: 'addParameter'
index: 136
name: 'tabBarTheme'
style: optional_named
argumentValue:
expression: 'TabBarThemeData(indicatorColor: {% indicatorColor %})'
requiredIf: "indicatorColor != ''"
variables:
indicatorColor:
kind: 'fragment'
value: 'arguments[indicatorColor]'
tabBarTheme:
kind: 'fragment'
value: 'arguments[tabBarTheme]'
# Changes made in https://github.com/flutter/flutter/pull/155072 # Changes made in https://github.com/flutter/flutter/pull/155072
- title: "Migrate 'ThemeData.dialogBackgroundColor' to 'DialogThemeData.backgroundColor'" - title: "Migrate 'ThemeData.dialogBackgroundColor' to 'DialogThemeData.backgroundColor'"
date: 2024-09-12 date: 2024-09-12

View File

@ -2565,14 +2565,16 @@ class _TabPageSelectorState extends State<TabPageSelector> {
// Hand coded defaults based on Material Design 2. // Hand coded defaults based on Material Design 2.
class _TabsDefaultsM2 extends TabBarThemeData { class _TabsDefaultsM2 extends TabBarThemeData {
const _TabsDefaultsM2(this.context, this.isScrollable) _TabsDefaultsM2(this.context, this.isScrollable) : super(indicatorSize: TabBarIndicatorSize.tab);
: super(indicatorSize: TabBarIndicatorSize.tab);
final BuildContext context; final BuildContext context;
late final ColorScheme _colors = Theme.of(context).colorScheme;
late final bool isDark = Theme.of(context).brightness == Brightness.dark;
late final Color primaryColor = isDark ? Colors.grey[900]! : Colors.blue;
final bool isScrollable; final bool isScrollable;
@override @override
Color? get indicatorColor => Theme.of(context).indicatorColor; Color? get indicatorColor => _colors.secondary == primaryColor ? Colors.white : _colors.secondary;
@override @override
Color? get labelColor => Theme.of(context).primaryTextTheme.bodyLarge!.color!; Color? get labelColor => Theme.of(context).primaryTextTheme.bodyLarge!.color!;

View File

@ -286,7 +286,6 @@ class ThemeData with Diagnosticable {
Color? highlightColor, Color? highlightColor,
Color? hintColor, Color? hintColor,
Color? hoverColor, Color? hoverColor,
Color? indicatorColor,
Color? primaryColor, Color? primaryColor,
Color? primaryColorDark, Color? primaryColorDark,
Color? primaryColorLight, Color? primaryColorLight,
@ -365,6 +364,11 @@ class ThemeData with Diagnosticable {
'This feature was deprecated after v3.27.0-0.1.pre.', 'This feature was deprecated after v3.27.0-0.1.pre.',
) )
Color? dialogBackgroundColor, Color? dialogBackgroundColor,
@Deprecated(
'Use TabBarThemeData.indicatorColor instead. '
'This feature was deprecated after v3.28.0-1.0.pre.',
)
Color? indicatorColor,
}) { }) {
// GENERAL CONFIGURATION // GENERAL CONFIGURATION
cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault(); cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
@ -459,7 +463,6 @@ class ThemeData with Diagnosticable {
unselectedWidgetColor ??= isDark ? Colors.white70 : Colors.black54; unselectedWidgetColor ??= isDark ? Colors.white70 : Colors.black54;
// Spec doesn't specify a dark theme secondaryHeaderColor, this is a guess. // Spec doesn't specify a dark theme secondaryHeaderColor, this is a guess.
secondaryHeaderColor ??= isDark ? Colors.grey[700]! : primarySwatch[50]!; secondaryHeaderColor ??= isDark ? Colors.grey[700]! : primarySwatch[50]!;
indicatorColor ??= colorScheme.secondary == primaryColor ? Colors.white : colorScheme.secondary;
hintColor ??= isDark ? Colors.white60 : Colors.black.withOpacity(0.6); hintColor ??= isDark ? Colors.white60 : Colors.black.withOpacity(0.6);
// The default [buttonTheme] is here because it doesn't use the defaults for // The default [buttonTheme] is here because it doesn't use the defaults for
// [disabledColor], [highlightColor], and [splashColor]. // [disabledColor], [highlightColor], and [splashColor].
@ -580,6 +583,7 @@ class ThemeData with Diagnosticable {
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
buttonBarTheme ??= const ButtonBarThemeData(); buttonBarTheme ??= const ButtonBarThemeData();
dialogBackgroundColor ??= isDark ? Colors.grey[800]! : Colors.white; dialogBackgroundColor ??= isDark ? Colors.grey[800]! : Colors.white;
indicatorColor ??= colorScheme.secondary == primaryColor ? Colors.white : colorScheme.secondary;
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.
@ -609,7 +613,6 @@ class ThemeData with Diagnosticable {
highlightColor: highlightColor, highlightColor: highlightColor,
hintColor: hintColor, hintColor: hintColor,
hoverColor: hoverColor, hoverColor: hoverColor,
indicatorColor: indicatorColor,
primaryColor: primaryColor, primaryColor: primaryColor,
primaryColorDark: primaryColorDark, primaryColorDark: primaryColorDark,
primaryColorLight: primaryColorLight, primaryColorLight: primaryColorLight,
@ -673,6 +676,7 @@ class ThemeData with Diagnosticable {
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
buttonBarTheme: buttonBarTheme, buttonBarTheme: buttonBarTheme,
dialogBackgroundColor: dialogBackgroundColor, dialogBackgroundColor: dialogBackgroundColor,
indicatorColor: indicatorColor,
); );
} }
@ -715,7 +719,6 @@ class ThemeData with Diagnosticable {
required this.highlightColor, required this.highlightColor,
required this.hintColor, required this.hintColor,
required this.hoverColor, required this.hoverColor,
required this.indicatorColor,
required this.primaryColor, required this.primaryColor,
required this.primaryColorDark, required this.primaryColorDark,
required this.primaryColorLight, required this.primaryColorLight,
@ -787,6 +790,11 @@ class ThemeData with Diagnosticable {
'This feature was deprecated after v3.27.0-0.1.pre.', 'This feature was deprecated after v3.27.0-0.1.pre.',
) )
required this.dialogBackgroundColor, required this.dialogBackgroundColor,
@Deprecated(
'Use TabBarThemeData.indicatorColor instead. '
'This feature was deprecated after v3.28.0-1.0.pre.',
)
required this.indicatorColor,
}) : // DEPRECATED (newest deprecations at the bottom) }) : // DEPRECATED (newest deprecations at the bottom)
// should not be `required`, use getter pattern to avoid breakages. // should not be `required`, use getter pattern to avoid breakages.
_buttonBarTheme = buttonBarTheme, _buttonBarTheme = buttonBarTheme,
@ -1204,9 +1212,6 @@ class ThemeData with Diagnosticable {
/// component. /// component.
final Color hoverColor; final Color hoverColor;
/// The color of the selected tab indicator in a tab bar.
final Color indicatorColor;
/// The background color for major parts of the app (toolbars, tab bars, etc) /// The background color for major parts of the app (toolbars, tab bars, etc)
/// ///
/// The theme's [colorScheme] property contains [ColorScheme.primary], as /// The theme's [colorScheme] property contains [ColorScheme.primary], as
@ -1451,6 +1456,13 @@ class ThemeData with Diagnosticable {
) )
final Color dialogBackgroundColor; final Color dialogBackgroundColor;
/// The color of the selected tab indicator in a tab bar.
@Deprecated(
'Use TabBarThemeData.indicatorColor instead. '
'This feature was deprecated after v3.28.0-1.0.pre.',
)
final Color indicatorColor;
/// 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].
@ -1486,7 +1498,6 @@ class ThemeData with Diagnosticable {
Color? highlightColor, Color? highlightColor,
Color? hintColor, Color? hintColor,
Color? hoverColor, Color? hoverColor,
Color? indicatorColor,
Color? primaryColor, Color? primaryColor,
Color? primaryColorDark, Color? primaryColorDark,
Color? primaryColorLight, Color? primaryColorLight,
@ -1568,6 +1579,11 @@ class ThemeData with Diagnosticable {
'This feature was deprecated after v3.27.0-0.1.pre.', 'This feature was deprecated after v3.27.0-0.1.pre.',
) )
Color? dialogBackgroundColor, Color? dialogBackgroundColor,
@Deprecated(
'Use TabBarThemeData.indicatorColor instead. '
'This feature was deprecated after v3.28.0-1.0.pre.',
)
Color? indicatorColor,
}) { }) {
cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault(); cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
@ -1628,7 +1644,6 @@ class ThemeData with Diagnosticable {
highlightColor: highlightColor ?? this.highlightColor, highlightColor: highlightColor ?? this.highlightColor,
hintColor: hintColor ?? this.hintColor, hintColor: hintColor ?? this.hintColor,
hoverColor: hoverColor ?? this.hoverColor, hoverColor: hoverColor ?? this.hoverColor,
indicatorColor: indicatorColor ?? this.indicatorColor,
primaryColor: primaryColor ?? this.primaryColor, primaryColor: primaryColor ?? this.primaryColor,
primaryColorDark: primaryColorDark ?? this.primaryColorDark, primaryColorDark: primaryColorDark ?? this.primaryColorDark,
primaryColorLight: primaryColorLight ?? this.primaryColorLight, primaryColorLight: primaryColorLight ?? this.primaryColorLight,
@ -1692,6 +1707,7 @@ class ThemeData with Diagnosticable {
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
buttonBarTheme: buttonBarTheme ?? _buttonBarTheme, buttonBarTheme: buttonBarTheme ?? _buttonBarTheme,
dialogBackgroundColor: dialogBackgroundColor ?? this.dialogBackgroundColor, dialogBackgroundColor: dialogBackgroundColor ?? this.dialogBackgroundColor,
indicatorColor: indicatorColor ?? this.indicatorColor,
); );
} }
@ -1835,7 +1851,6 @@ class ThemeData with Diagnosticable {
highlightColor: Color.lerp(a.highlightColor, b.highlightColor, t)!, highlightColor: Color.lerp(a.highlightColor, b.highlightColor, t)!,
hintColor: Color.lerp(a.hintColor, b.hintColor, t)!, hintColor: Color.lerp(a.hintColor, b.hintColor, t)!,
hoverColor: Color.lerp(a.hoverColor, b.hoverColor, t)!, hoverColor: Color.lerp(a.hoverColor, b.hoverColor, t)!,
indicatorColor: Color.lerp(a.indicatorColor, b.indicatorColor, t)!,
primaryColor: Color.lerp(a.primaryColor, b.primaryColor, t)!, primaryColor: Color.lerp(a.primaryColor, b.primaryColor, t)!,
primaryColorDark: Color.lerp(a.primaryColorDark, b.primaryColorDark, t)!, primaryColorDark: Color.lerp(a.primaryColorDark, b.primaryColorDark, t)!,
primaryColorLight: Color.lerp(a.primaryColorLight, b.primaryColorLight, t)!, primaryColorLight: Color.lerp(a.primaryColorLight, b.primaryColorLight, t)!,
@ -1921,6 +1936,7 @@ class ThemeData with Diagnosticable {
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
buttonBarTheme: ButtonBarThemeData.lerp(a.buttonBarTheme, b.buttonBarTheme, t), buttonBarTheme: ButtonBarThemeData.lerp(a.buttonBarTheme, b.buttonBarTheme, t),
dialogBackgroundColor: Color.lerp(a.dialogBackgroundColor, b.dialogBackgroundColor, t)!, dialogBackgroundColor: Color.lerp(a.dialogBackgroundColor, b.dialogBackgroundColor, t)!,
indicatorColor: Color.lerp(a.indicatorColor, b.indicatorColor, t)!,
); );
} }
@ -1957,7 +1973,6 @@ class ThemeData with Diagnosticable {
other.highlightColor == highlightColor && other.highlightColor == highlightColor &&
other.hintColor == hintColor && other.hintColor == hintColor &&
other.hoverColor == hoverColor && other.hoverColor == hoverColor &&
other.indicatorColor == indicatorColor &&
other.primaryColor == primaryColor && other.primaryColor == primaryColor &&
other.primaryColorDark == primaryColorDark && other.primaryColorDark == primaryColorDark &&
other.primaryColorLight == primaryColorLight && other.primaryColorLight == primaryColorLight &&
@ -2020,7 +2035,8 @@ class ThemeData with Diagnosticable {
other.tooltipTheme == tooltipTheme && other.tooltipTheme == tooltipTheme &&
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
other.buttonBarTheme == buttonBarTheme && other.buttonBarTheme == buttonBarTheme &&
other.dialogBackgroundColor == dialogBackgroundColor; other.dialogBackgroundColor == dialogBackgroundColor &&
other.indicatorColor == indicatorColor;
} }
@override @override
@ -2056,7 +2072,6 @@ class ThemeData with Diagnosticable {
highlightColor, highlightColor,
hintColor, hintColor,
hoverColor, hoverColor,
indicatorColor,
primaryColor, primaryColor,
primaryColorDark, primaryColorDark,
primaryColorLight, primaryColorLight,
@ -2120,6 +2135,7 @@ class ThemeData with Diagnosticable {
// DEPRECATED (newest deprecations at the bottom) // DEPRECATED (newest deprecations at the bottom)
buttonBarTheme, buttonBarTheme,
dialogBackgroundColor, dialogBackgroundColor,
indicatorColor,
]; ];
return Object.hashAll(values); return Object.hashAll(values);
} }
@ -2299,14 +2315,6 @@ class ThemeData with Diagnosticable {
level: DiagnosticLevel.debug, level: DiagnosticLevel.debug,
), ),
); );
properties.add(
ColorProperty(
'indicatorColor',
indicatorColor,
defaultValue: defaultData.indicatorColor,
level: DiagnosticLevel.debug,
),
);
properties.add( properties.add(
ColorProperty( ColorProperty(
'primaryColorDark', 'primaryColorDark',
@ -2761,6 +2769,14 @@ class ThemeData with Diagnosticable {
level: DiagnosticLevel.debug, level: DiagnosticLevel.debug,
), ),
); );
properties.add(
ColorProperty(
'indicatorColor',
indicatorColor,
defaultValue: defaultData.indicatorColor,
level: DiagnosticLevel.debug,
),
);
} }
} }

View File

@ -1473,13 +1473,11 @@ void main() {
final TabController controller = TabController(vsync: const TestVSync(), length: tabs.length); final TabController controller = TabController(vsync: const TestVSync(), length: tabs.length);
addTearDown(controller.dispose); addTearDown(controller.dispose);
const Color themeIndicatorColor = Color(0xffff0000);
const Color tabBarThemeIndicatorColor = Color(0xffffff00); const Color tabBarThemeIndicatorColor = Color(0xffffff00);
Widget buildTabBar({Color? themeIndicatorColor, Color? tabBarThemeIndicatorColor}) { Widget buildTabBar({Color? tabBarThemeIndicatorColor}) {
return MaterialApp( return MaterialApp(
theme: ThemeData( theme: ThemeData(
indicatorColor: themeIndicatorColor,
tabBarTheme: TabBarThemeData(indicatorColor: tabBarThemeIndicatorColor), tabBarTheme: TabBarThemeData(indicatorColor: tabBarThemeIndicatorColor),
useMaterial3: false, useMaterial3: false,
), ),
@ -1492,15 +1490,9 @@ void main() {
); );
} }
await tester.pumpWidget(buildTabBar(themeIndicatorColor: themeIndicatorColor));
RenderBox tabBarBox = tester.firstRenderObject<RenderBox>(find.byType(TabBar));
expect(tabBarBox, paints..line(color: themeIndicatorColor));
await tester.pumpWidget(buildTabBar(tabBarThemeIndicatorColor: tabBarThemeIndicatorColor)); await tester.pumpWidget(buildTabBar(tabBarThemeIndicatorColor: tabBarThemeIndicatorColor));
await tester.pumpAndSettle();
tabBarBox = tester.firstRenderObject<RenderBox>(find.byType(TabBar)); final RenderBox tabBarBox = tester.firstRenderObject<RenderBox>(find.byType(TabBar));
expect(tabBarBox, paints..line(color: tabBarThemeIndicatorColor)); expect(tabBarBox, paints..line(color: tabBarThemeIndicatorColor));
}); });

View File

@ -893,14 +893,12 @@ void main() {
canvasColor: Colors.black, canvasColor: Colors.black,
cardColor: Colors.black, cardColor: Colors.black,
colorScheme: const ColorScheme.light(), colorScheme: const ColorScheme.light(),
dialogBackgroundColor: Colors.black,
disabledColor: Colors.black, disabledColor: Colors.black,
dividerColor: Colors.black, dividerColor: Colors.black,
focusColor: Colors.black, focusColor: Colors.black,
highlightColor: Colors.black, highlightColor: Colors.black,
hintColor: Colors.black, hintColor: Colors.black,
hoverColor: Colors.black, hoverColor: Colors.black,
indicatorColor: Colors.black,
primaryColor: Colors.black, primaryColor: Colors.black,
primaryColorDark: Colors.black, primaryColorDark: Colors.black,
primaryColorLight: Colors.black, primaryColorLight: Colors.black,
@ -925,7 +923,6 @@ void main() {
type: BottomNavigationBarType.fixed, type: BottomNavigationBarType.fixed,
), ),
bottomSheetTheme: const BottomSheetThemeData(backgroundColor: Colors.black), bottomSheetTheme: const BottomSheetThemeData(backgroundColor: Colors.black),
buttonBarTheme: const ButtonBarThemeData(alignment: MainAxisAlignment.start),
buttonTheme: const ButtonThemeData(colorScheme: ColorScheme.dark()), buttonTheme: const ButtonThemeData(colorScheme: ColorScheme.dark()),
cardTheme: const CardThemeData(color: Colors.black), cardTheme: const CardThemeData(color: Colors.black),
checkboxTheme: const CheckboxThemeData(), checkboxTheme: const CheckboxThemeData(),
@ -980,6 +977,10 @@ 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)
buttonBarTheme: const ButtonBarThemeData(alignment: MainAxisAlignment.start),
dialogBackgroundColor: Colors.black,
indicatorColor: Colors.black,
); );
final SliderThemeData otherSliderTheme = SliderThemeData.fromPrimaryColors( final SliderThemeData otherSliderTheme = SliderThemeData.fromPrimaryColors(
@ -1018,19 +1019,16 @@ void main() {
splashFactory: InkRipple.splashFactory, splashFactory: InkRipple.splashFactory,
useMaterial3: true, useMaterial3: true,
visualDensity: VisualDensity.standard, visualDensity: VisualDensity.standard,
// COLOR // COLOR
canvasColor: Colors.white, canvasColor: Colors.white,
cardColor: Colors.white, cardColor: Colors.white,
colorScheme: const ColorScheme.light(), colorScheme: const ColorScheme.light(),
dialogBackgroundColor: Colors.white,
disabledColor: Colors.white, disabledColor: Colors.white,
dividerColor: Colors.white, dividerColor: Colors.white,
focusColor: Colors.white, focusColor: Colors.white,
highlightColor: Colors.white, highlightColor: Colors.white,
hintColor: Colors.white, hintColor: Colors.white,
hoverColor: Colors.white, hoverColor: Colors.white,
indicatorColor: Colors.white,
primaryColor: Colors.white, primaryColor: Colors.white,
primaryColorDark: Colors.white, primaryColorDark: Colors.white,
primaryColorLight: Colors.white, primaryColorLight: Colors.white,
@ -1039,14 +1037,12 @@ void main() {
shadowColor: Colors.white, shadowColor: Colors.white,
splashColor: Colors.white, splashColor: Colors.white,
unselectedWidgetColor: Colors.white, unselectedWidgetColor: Colors.white,
// TYPOGRAPHY & ICONOGRAPHY // TYPOGRAPHY & ICONOGRAPHY
iconTheme: ThemeData.light().iconTheme, iconTheme: ThemeData.light().iconTheme,
primaryIconTheme: ThemeData.light().iconTheme, primaryIconTheme: ThemeData.light().iconTheme,
primaryTextTheme: ThemeData.light().textTheme, primaryTextTheme: ThemeData.light().textTheme,
textTheme: ThemeData.light().textTheme, textTheme: ThemeData.light().textTheme,
typography: Typography.material2018(platform: TargetPlatform.iOS), typography: Typography.material2018(platform: TargetPlatform.iOS),
// COMPONENT THEMES // COMPONENT THEMES
actionIconTheme: const ActionIconThemeData(), actionIconTheme: const ActionIconThemeData(),
appBarTheme: const AppBarTheme(backgroundColor: Colors.white), appBarTheme: const AppBarTheme(backgroundColor: Colors.white),
@ -1057,7 +1053,6 @@ void main() {
type: BottomNavigationBarType.shifting, type: BottomNavigationBarType.shifting,
), ),
bottomSheetTheme: const BottomSheetThemeData(backgroundColor: Colors.white), bottomSheetTheme: const BottomSheetThemeData(backgroundColor: Colors.white),
buttonBarTheme: const ButtonBarThemeData(alignment: MainAxisAlignment.end),
buttonTheme: const ButtonThemeData(colorScheme: ColorScheme.light()), buttonTheme: const ButtonThemeData(colorScheme: ColorScheme.light()),
cardTheme: const CardThemeData(color: Colors.white), cardTheme: const CardThemeData(color: Colors.white),
checkboxTheme: const CheckboxThemeData(), checkboxTheme: const CheckboxThemeData(),
@ -1102,6 +1097,10 @@ 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)
buttonBarTheme: const ButtonBarThemeData(alignment: MainAxisAlignment.end),
dialogBackgroundColor: Colors.white,
indicatorColor: Colors.white,
); );
final ThemeData themeDataCopy = theme.copyWith( final ThemeData themeDataCopy = theme.copyWith(
@ -1123,19 +1122,16 @@ void main() {
splashFactory: otherTheme.splashFactory, splashFactory: otherTheme.splashFactory,
useMaterial3: otherTheme.useMaterial3, useMaterial3: otherTheme.useMaterial3,
visualDensity: otherTheme.visualDensity, visualDensity: otherTheme.visualDensity,
// COLOR // COLOR
canvasColor: otherTheme.canvasColor, canvasColor: otherTheme.canvasColor,
cardColor: otherTheme.cardColor, cardColor: otherTheme.cardColor,
colorScheme: otherTheme.colorScheme, colorScheme: otherTheme.colorScheme,
dialogBackgroundColor: otherTheme.dialogBackgroundColor,
disabledColor: otherTheme.disabledColor, disabledColor: otherTheme.disabledColor,
dividerColor: otherTheme.dividerColor, dividerColor: otherTheme.dividerColor,
focusColor: otherTheme.focusColor, focusColor: otherTheme.focusColor,
highlightColor: otherTheme.highlightColor, highlightColor: otherTheme.highlightColor,
hintColor: otherTheme.hintColor, hintColor: otherTheme.hintColor,
hoverColor: otherTheme.hoverColor, hoverColor: otherTheme.hoverColor,
indicatorColor: otherTheme.indicatorColor,
primaryColor: otherTheme.primaryColor, primaryColor: otherTheme.primaryColor,
primaryColorDark: otherTheme.primaryColorDark, primaryColorDark: otherTheme.primaryColorDark,
primaryColorLight: otherTheme.primaryColorLight, primaryColorLight: otherTheme.primaryColorLight,
@ -1144,14 +1140,12 @@ void main() {
shadowColor: otherTheme.shadowColor, shadowColor: otherTheme.shadowColor,
splashColor: otherTheme.splashColor, splashColor: otherTheme.splashColor,
unselectedWidgetColor: otherTheme.unselectedWidgetColor, unselectedWidgetColor: otherTheme.unselectedWidgetColor,
// TYPOGRAPHY & ICONOGRAPHY // TYPOGRAPHY & ICONOGRAPHY
iconTheme: otherTheme.iconTheme, iconTheme: otherTheme.iconTheme,
primaryIconTheme: otherTheme.primaryIconTheme, primaryIconTheme: otherTheme.primaryIconTheme,
primaryTextTheme: otherTheme.primaryTextTheme, primaryTextTheme: otherTheme.primaryTextTheme,
textTheme: otherTheme.textTheme, textTheme: otherTheme.textTheme,
typography: otherTheme.typography, typography: otherTheme.typography,
// COMPONENT THEMES // COMPONENT THEMES
actionIconTheme: otherTheme.actionIconTheme, actionIconTheme: otherTheme.actionIconTheme,
appBarTheme: otherTheme.appBarTheme, appBarTheme: otherTheme.appBarTheme,
@ -1160,7 +1154,6 @@ void main() {
bottomAppBarTheme: otherTheme.bottomAppBarTheme, bottomAppBarTheme: otherTheme.bottomAppBarTheme,
bottomNavigationBarTheme: otherTheme.bottomNavigationBarTheme, bottomNavigationBarTheme: otherTheme.bottomNavigationBarTheme,
bottomSheetTheme: otherTheme.bottomSheetTheme, bottomSheetTheme: otherTheme.bottomSheetTheme,
buttonBarTheme: otherTheme.buttonBarTheme,
buttonTheme: otherTheme.buttonTheme, buttonTheme: otherTheme.buttonTheme,
cardTheme: otherTheme.cardTheme, cardTheme: otherTheme.cardTheme,
checkboxTheme: otherTheme.checkboxTheme, checkboxTheme: otherTheme.checkboxTheme,
@ -1197,6 +1190,10 @@ 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)
buttonBarTheme: otherTheme.buttonBarTheme,
dialogBackgroundColor: otherTheme.dialogBackgroundColor,
indicatorColor: otherTheme.indicatorColor,
); );
// 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
@ -1217,19 +1214,16 @@ void main() {
expect(themeDataCopy.splashFactory, equals(otherTheme.splashFactory)); expect(themeDataCopy.splashFactory, equals(otherTheme.splashFactory));
expect(themeDataCopy.useMaterial3, equals(otherTheme.useMaterial3)); expect(themeDataCopy.useMaterial3, equals(otherTheme.useMaterial3));
expect(themeDataCopy.visualDensity, equals(otherTheme.visualDensity)); expect(themeDataCopy.visualDensity, equals(otherTheme.visualDensity));
// COLOR // COLOR
expect(themeDataCopy.canvasColor, equals(otherTheme.canvasColor)); expect(themeDataCopy.canvasColor, equals(otherTheme.canvasColor));
expect(themeDataCopy.cardColor, equals(otherTheme.cardColor)); expect(themeDataCopy.cardColor, equals(otherTheme.cardColor));
expect(themeDataCopy.colorScheme, equals(otherTheme.colorScheme)); expect(themeDataCopy.colorScheme, equals(otherTheme.colorScheme));
expect(themeDataCopy.dialogBackgroundColor, equals(otherTheme.dialogBackgroundColor));
expect(themeDataCopy.disabledColor, equals(otherTheme.disabledColor)); expect(themeDataCopy.disabledColor, equals(otherTheme.disabledColor));
expect(themeDataCopy.dividerColor, equals(otherTheme.dividerColor)); expect(themeDataCopy.dividerColor, equals(otherTheme.dividerColor));
expect(themeDataCopy.focusColor, equals(otherTheme.focusColor)); expect(themeDataCopy.focusColor, equals(otherTheme.focusColor));
expect(themeDataCopy.highlightColor, equals(otherTheme.highlightColor)); expect(themeDataCopy.highlightColor, equals(otherTheme.highlightColor));
expect(themeDataCopy.hintColor, equals(otherTheme.hintColor)); expect(themeDataCopy.hintColor, equals(otherTheme.hintColor));
expect(themeDataCopy.hoverColor, equals(otherTheme.hoverColor)); expect(themeDataCopy.hoverColor, equals(otherTheme.hoverColor));
expect(themeDataCopy.indicatorColor, equals(otherTheme.indicatorColor));
expect(themeDataCopy.primaryColor, equals(otherTheme.primaryColor)); expect(themeDataCopy.primaryColor, equals(otherTheme.primaryColor));
expect(themeDataCopy.primaryColorDark, equals(otherTheme.primaryColorDark)); expect(themeDataCopy.primaryColorDark, equals(otherTheme.primaryColorDark));
expect(themeDataCopy.primaryColorLight, equals(otherTheme.primaryColorLight)); expect(themeDataCopy.primaryColorLight, equals(otherTheme.primaryColorLight));
@ -1238,14 +1232,12 @@ void main() {
expect(themeDataCopy.shadowColor, equals(otherTheme.shadowColor)); expect(themeDataCopy.shadowColor, equals(otherTheme.shadowColor));
expect(themeDataCopy.splashColor, equals(otherTheme.splashColor)); expect(themeDataCopy.splashColor, equals(otherTheme.splashColor));
expect(themeDataCopy.unselectedWidgetColor, equals(otherTheme.unselectedWidgetColor)); expect(themeDataCopy.unselectedWidgetColor, equals(otherTheme.unselectedWidgetColor));
// TYPOGRAPHY & ICONOGRAPHY // TYPOGRAPHY & ICONOGRAPHY
expect(themeDataCopy.iconTheme, equals(otherTheme.iconTheme)); expect(themeDataCopy.iconTheme, equals(otherTheme.iconTheme));
expect(themeDataCopy.primaryIconTheme, equals(otherTheme.primaryIconTheme)); expect(themeDataCopy.primaryIconTheme, equals(otherTheme.primaryIconTheme));
expect(themeDataCopy.primaryTextTheme, equals(otherTheme.primaryTextTheme)); expect(themeDataCopy.primaryTextTheme, equals(otherTheme.primaryTextTheme));
expect(themeDataCopy.textTheme, equals(otherTheme.textTheme)); expect(themeDataCopy.textTheme, equals(otherTheme.textTheme));
expect(themeDataCopy.typography, equals(otherTheme.typography)); expect(themeDataCopy.typography, equals(otherTheme.typography));
// COMPONENT THEMES // COMPONENT THEMES
expect(themeDataCopy.actionIconTheme, equals(otherTheme.actionIconTheme)); expect(themeDataCopy.actionIconTheme, equals(otherTheme.actionIconTheme));
expect(themeDataCopy.appBarTheme, equals(otherTheme.appBarTheme)); expect(themeDataCopy.appBarTheme, equals(otherTheme.appBarTheme));
@ -1254,7 +1246,6 @@ void main() {
expect(themeDataCopy.bottomAppBarTheme, equals(otherTheme.bottomAppBarTheme)); expect(themeDataCopy.bottomAppBarTheme, equals(otherTheme.bottomAppBarTheme));
expect(themeDataCopy.bottomNavigationBarTheme, equals(otherTheme.bottomNavigationBarTheme)); expect(themeDataCopy.bottomNavigationBarTheme, equals(otherTheme.bottomNavigationBarTheme));
expect(themeDataCopy.bottomSheetTheme, equals(otherTheme.bottomSheetTheme)); expect(themeDataCopy.bottomSheetTheme, equals(otherTheme.bottomSheetTheme));
expect(themeDataCopy.buttonBarTheme, equals(otherTheme.buttonBarTheme));
expect(themeDataCopy.buttonTheme, equals(otherTheme.buttonTheme)); expect(themeDataCopy.buttonTheme, equals(otherTheme.buttonTheme));
expect(themeDataCopy.cardTheme, equals(otherTheme.cardTheme)); expect(themeDataCopy.cardTheme, equals(otherTheme.cardTheme));
expect(themeDataCopy.checkboxTheme, equals(otherTheme.checkboxTheme)); expect(themeDataCopy.checkboxTheme, equals(otherTheme.checkboxTheme));
@ -1302,6 +1293,10 @@ 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.buttonBarTheme, equals(otherTheme.buttonBarTheme));
expect(themeDataCopy.dialogBackgroundColor, equals(otherTheme.dialogBackgroundColor));
expect(themeDataCopy.indicatorColor, equals(otherTheme.indicatorColor));
}); });
testWidgets('ThemeData.toString has less than 200 characters output', ( testWidgets('ThemeData.toString has less than 200 characters output', (
@ -1383,8 +1378,6 @@ void main() {
'unselectedWidgetColor', 'unselectedWidgetColor',
'disabledColor', 'disabledColor',
'secondaryHeaderColor', 'secondaryHeaderColor',
'dialogBackgroundColor',
'indicatorColor',
'hintColor', 'hintColor',
// TYPOGRAPHY & ICONOGRAPHY // TYPOGRAPHY & ICONOGRAPHY
'typography', 'typography',
@ -1400,7 +1393,6 @@ void main() {
'bottomAppBarTheme', 'bottomAppBarTheme',
'bottomNavigationBarTheme', 'bottomNavigationBarTheme',
'bottomSheetTheme', 'bottomSheetTheme',
'buttonBarTheme',
'buttonTheme', 'buttonTheme',
'cardTheme', 'cardTheme',
'checkboxTheme', 'checkboxTheme',
@ -1439,6 +1431,10 @@ void main() {
'timePickerTheme', 'timePickerTheme',
'toggleButtonsTheme', 'toggleButtonsTheme',
'tooltipTheme', 'tooltipTheme',
// DEPRECATED (newest deprecations at the bottom)
'buttonBarTheme',
'dialogBackgroundColor',
'indicatorColor',
}; };
final DiagnosticPropertiesBuilder properties = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder properties = DiagnosticPropertiesBuilder();

View File

@ -327,4 +327,18 @@ void main() {
dialogTheme: DialogThemeData(backgroundColor: Colors.red), dialogTheme: DialogThemeData(backgroundColor: Colors.red),
); );
themeData.dialogBackgroundColor; // Removing field reference not supported. themeData.dialogBackgroundColor; // Removing field reference not supported.
// Changes made in https://github.com/flutter/flutter/pull/160024
ThemeData themeData = ThemeData();
themeData = ThemeData(indicatorColor: Colors.red);
themeData = ThemeData(
indicatorColor: Colors.red,
tabBarTheme: TabBarThemeData(indicatorColor: Colors.green),
);
themeData = themeData.copyWith(indicatorColor: Colors.red);
themeData = themeData.copyWith(
indicatorColor: Colors.red,
tabBarTheme: TabBarThemeData(indicatorColor: Colors.green),
);
themeData.indicatorColor; // Removing field reference not supported.
} }

View File

@ -401,4 +401,16 @@ void main() {
dialogTheme: DialogThemeData(backgroundColor: Colors.red), dialogTheme: DialogThemeData(backgroundColor: Colors.red),
); );
themeData.dialogBackgroundColor; // Removing field reference not supported. themeData.dialogBackgroundColor; // Removing field reference not supported.
// Changes made in https://github.com/flutter/flutter/pull/160024
ThemeData themeData = ThemeData();
themeData = ThemeData(tabBarTheme: TabBarThemeData(indicatorColor: Colors.red));
themeData = ThemeData(
tabBarTheme: TabBarThemeData(indicatorColor: Colors.green),
);
themeData = themeData.copyWith(tabBarTheme: TabBarThemeData(indicatorColor: Colors.red));
themeData = themeData.copyWith(
tabBarTheme: TabBarThemeData(indicatorColor: Colors.green),
);
themeData.indicatorColor; // Removing field reference not supported.
} }