Change cardTheme
, dialogTheme
, and tabBarTheme
type to xxxThemeData
(#157292)
Following https://github.com/flutter/flutter/pull/156253, this PR changes the parameter type for `cardTheme`, `dialogTheme` and `tabBarTheme` from `Object?` to `xxxThemeData?`. The last potential failures in g3 have been removed: cl/692314033 ## 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.
This commit is contained in:
parent
d6a6e95c32
commit
7e155bc18e
@ -313,14 +313,12 @@ class ThemeData with Diagnosticable {
|
|||||||
BottomNavigationBarThemeData? bottomNavigationBarTheme,
|
BottomNavigationBarThemeData? bottomNavigationBarTheme,
|
||||||
BottomSheetThemeData? bottomSheetTheme,
|
BottomSheetThemeData? bottomSheetTheme,
|
||||||
ButtonThemeData? buttonTheme,
|
ButtonThemeData? buttonTheme,
|
||||||
// TODO(QuncCccccc): Change the parameter type to CardThemeData
|
CardThemeData? cardTheme,
|
||||||
Object? cardTheme,
|
|
||||||
CheckboxThemeData? checkboxTheme,
|
CheckboxThemeData? checkboxTheme,
|
||||||
ChipThemeData? chipTheme,
|
ChipThemeData? chipTheme,
|
||||||
DataTableThemeData? dataTableTheme,
|
DataTableThemeData? dataTableTheme,
|
||||||
DatePickerThemeData? datePickerTheme,
|
DatePickerThemeData? datePickerTheme,
|
||||||
// TODO(QuncCccccc): Change the parameter type to DialogThemeData
|
DialogThemeData? dialogTheme,
|
||||||
Object? dialogTheme,
|
|
||||||
DividerThemeData? dividerTheme,
|
DividerThemeData? dividerTheme,
|
||||||
DrawerThemeData? drawerTheme,
|
DrawerThemeData? drawerTheme,
|
||||||
DropdownMenuThemeData? dropdownMenuTheme,
|
DropdownMenuThemeData? dropdownMenuTheme,
|
||||||
@ -346,8 +344,7 @@ class ThemeData with Diagnosticable {
|
|||||||
SliderThemeData? sliderTheme,
|
SliderThemeData? sliderTheme,
|
||||||
SnackBarThemeData? snackBarTheme,
|
SnackBarThemeData? snackBarTheme,
|
||||||
SwitchThemeData? switchTheme,
|
SwitchThemeData? switchTheme,
|
||||||
// TODO(QuncCccccc): Change the parameter type to TabBarThemeData
|
TabBarThemeData? tabBarTheme,
|
||||||
Object? tabBarTheme,
|
|
||||||
TextButtonThemeData? textButtonTheme,
|
TextButtonThemeData? textButtonTheme,
|
||||||
TextSelectionThemeData? textSelectionTheme,
|
TextSelectionThemeData? textSelectionTheme,
|
||||||
TimePickerThemeData? timePickerTheme,
|
TimePickerThemeData? timePickerTheme,
|
||||||
@ -519,27 +516,11 @@ class ThemeData with Diagnosticable {
|
|||||||
bottomAppBarTheme ??= const BottomAppBarTheme();
|
bottomAppBarTheme ??= const BottomAppBarTheme();
|
||||||
bottomNavigationBarTheme ??= const BottomNavigationBarThemeData();
|
bottomNavigationBarTheme ??= const BottomNavigationBarThemeData();
|
||||||
bottomSheetTheme ??= const BottomSheetThemeData();
|
bottomSheetTheme ??= const BottomSheetThemeData();
|
||||||
// TODO(QuncCccccc): Clean it up once the type of `cardTheme` is changed to `CardThemeData`
|
|
||||||
if (cardTheme != null) {
|
|
||||||
if (cardTheme is CardTheme) {
|
|
||||||
cardTheme = cardTheme.data;
|
|
||||||
} else if (cardTheme is! CardThemeData) {
|
|
||||||
throw ArgumentError('cardTheme must be either a CardThemeData or a CardTheme');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cardTheme ??= const CardThemeData();
|
cardTheme ??= const CardThemeData();
|
||||||
checkboxTheme ??= const CheckboxThemeData();
|
checkboxTheme ??= const CheckboxThemeData();
|
||||||
chipTheme ??= const ChipThemeData();
|
chipTheme ??= const ChipThemeData();
|
||||||
dataTableTheme ??= const DataTableThemeData();
|
dataTableTheme ??= const DataTableThemeData();
|
||||||
datePickerTheme ??= const DatePickerThemeData();
|
datePickerTheme ??= const DatePickerThemeData();
|
||||||
// TODO(QuncCccccc): Clean this up once the type of `dialogTheme` is changed to `DialogThemeData`
|
|
||||||
if (dialogTheme != null) {
|
|
||||||
if (dialogTheme is DialogTheme) {
|
|
||||||
dialogTheme = dialogTheme.data;
|
|
||||||
} else if (dialogTheme is! DialogThemeData) {
|
|
||||||
throw ArgumentError('dialogTheme must be either a DialogThemeData or a DialogTheme');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dialogTheme ??= const DialogThemeData();
|
dialogTheme ??= const DialogThemeData();
|
||||||
dividerTheme ??= const DividerThemeData();
|
dividerTheme ??= const DividerThemeData();
|
||||||
drawerTheme ??= const DrawerThemeData();
|
drawerTheme ??= const DrawerThemeData();
|
||||||
@ -566,14 +547,6 @@ class ThemeData with Diagnosticable {
|
|||||||
sliderTheme ??= const SliderThemeData();
|
sliderTheme ??= const SliderThemeData();
|
||||||
snackBarTheme ??= const SnackBarThemeData();
|
snackBarTheme ??= const SnackBarThemeData();
|
||||||
switchTheme ??= const SwitchThemeData();
|
switchTheme ??= const SwitchThemeData();
|
||||||
// TODO(QuncCccccc): Clean this up once the type of `tabBarTheme` is changed to `TabBarThemeData`
|
|
||||||
if (tabBarTheme != null) {
|
|
||||||
if (tabBarTheme is TabBarTheme) {
|
|
||||||
tabBarTheme = tabBarTheme.data;
|
|
||||||
} else if (tabBarTheme is! TabBarThemeData) {
|
|
||||||
throw ArgumentError('tabBarTheme must be either a TabBarThemeData or a TabBarTheme');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tabBarTheme ??= const TabBarThemeData();
|
tabBarTheme ??= const TabBarThemeData();
|
||||||
textButtonTheme ??= const TextButtonThemeData();
|
textButtonTheme ??= const TextButtonThemeData();
|
||||||
textSelectionTheme ??= const TextSelectionThemeData();
|
textSelectionTheme ??= const TextSelectionThemeData();
|
||||||
@ -636,12 +609,12 @@ class ThemeData with Diagnosticable {
|
|||||||
bottomNavigationBarTheme: bottomNavigationBarTheme,
|
bottomNavigationBarTheme: bottomNavigationBarTheme,
|
||||||
bottomSheetTheme: bottomSheetTheme,
|
bottomSheetTheme: bottomSheetTheme,
|
||||||
buttonTheme: buttonTheme,
|
buttonTheme: buttonTheme,
|
||||||
cardTheme: cardTheme as CardThemeData,
|
cardTheme: cardTheme,
|
||||||
checkboxTheme: checkboxTheme,
|
checkboxTheme: checkboxTheme,
|
||||||
chipTheme: chipTheme,
|
chipTheme: chipTheme,
|
||||||
dataTableTheme: dataTableTheme,
|
dataTableTheme: dataTableTheme,
|
||||||
datePickerTheme: datePickerTheme,
|
datePickerTheme: datePickerTheme,
|
||||||
dialogTheme: dialogTheme as DialogThemeData,
|
dialogTheme: dialogTheme,
|
||||||
dividerTheme: dividerTheme,
|
dividerTheme: dividerTheme,
|
||||||
drawerTheme: drawerTheme,
|
drawerTheme: drawerTheme,
|
||||||
dropdownMenuTheme: dropdownMenuTheme,
|
dropdownMenuTheme: dropdownMenuTheme,
|
||||||
@ -667,7 +640,7 @@ class ThemeData with Diagnosticable {
|
|||||||
sliderTheme: sliderTheme,
|
sliderTheme: sliderTheme,
|
||||||
snackBarTheme: snackBarTheme,
|
snackBarTheme: snackBarTheme,
|
||||||
switchTheme: switchTheme,
|
switchTheme: switchTheme,
|
||||||
tabBarTheme: tabBarTheme as TabBarThemeData,
|
tabBarTheme: tabBarTheme,
|
||||||
textButtonTheme: textButtonTheme,
|
textButtonTheme: textButtonTheme,
|
||||||
textSelectionTheme: textSelectionTheme,
|
textSelectionTheme: textSelectionTheme,
|
||||||
timePickerTheme: timePickerTheme,
|
timePickerTheme: timePickerTheme,
|
||||||
@ -1525,13 +1498,12 @@ class ThemeData with Diagnosticable {
|
|||||||
BottomNavigationBarThemeData? bottomNavigationBarTheme,
|
BottomNavigationBarThemeData? bottomNavigationBarTheme,
|
||||||
BottomSheetThemeData? bottomSheetTheme,
|
BottomSheetThemeData? bottomSheetTheme,
|
||||||
ButtonThemeData? buttonTheme,
|
ButtonThemeData? buttonTheme,
|
||||||
Object? cardTheme,
|
CardThemeData? cardTheme,
|
||||||
CheckboxThemeData? checkboxTheme,
|
CheckboxThemeData? checkboxTheme,
|
||||||
ChipThemeData? chipTheme,
|
ChipThemeData? chipTheme,
|
||||||
DataTableThemeData? dataTableTheme,
|
DataTableThemeData? dataTableTheme,
|
||||||
DatePickerThemeData? datePickerTheme,
|
DatePickerThemeData? datePickerTheme,
|
||||||
// TODO(QuncCccccc): Change the parameter type to DialogThemeData
|
DialogThemeData? dialogTheme,
|
||||||
Object? dialogTheme,
|
|
||||||
DividerThemeData? dividerTheme,
|
DividerThemeData? dividerTheme,
|
||||||
DrawerThemeData? drawerTheme,
|
DrawerThemeData? drawerTheme,
|
||||||
DropdownMenuThemeData? dropdownMenuTheme,
|
DropdownMenuThemeData? dropdownMenuTheme,
|
||||||
@ -1557,8 +1529,7 @@ class ThemeData with Diagnosticable {
|
|||||||
SliderThemeData? sliderTheme,
|
SliderThemeData? sliderTheme,
|
||||||
SnackBarThemeData? snackBarTheme,
|
SnackBarThemeData? snackBarTheme,
|
||||||
SwitchThemeData? switchTheme,
|
SwitchThemeData? switchTheme,
|
||||||
// TODO(QuncCccccc): Change the parameter type to TabBarThemeData
|
TabBarThemeData? tabBarTheme,
|
||||||
Object? tabBarTheme,
|
|
||||||
TextButtonThemeData? textButtonTheme,
|
TextButtonThemeData? textButtonTheme,
|
||||||
TextSelectionThemeData? textSelectionTheme,
|
TextSelectionThemeData? textSelectionTheme,
|
||||||
TimePickerThemeData? timePickerTheme,
|
TimePickerThemeData? timePickerTheme,
|
||||||
@ -1591,32 +1562,6 @@ class ThemeData with Diagnosticable {
|
|||||||
}) {
|
}) {
|
||||||
cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
|
cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
|
||||||
|
|
||||||
// TODO(QuncCccccc): Clean it up once the type of `cardTheme` is changed to `CardThemeData`
|
|
||||||
if (cardTheme != null) {
|
|
||||||
if (cardTheme is CardTheme) {
|
|
||||||
cardTheme = cardTheme.data;
|
|
||||||
} else if (cardTheme is! CardThemeData) {
|
|
||||||
throw ArgumentError('cardTheme must be either a CardThemeData or a CardTheme');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(QuncCccccc): Clean this up once the type of `dialogTheme` is changed to `DialogThemeData`
|
|
||||||
if (dialogTheme != null) {
|
|
||||||
if (dialogTheme is DialogTheme) {
|
|
||||||
dialogTheme = dialogTheme.data;
|
|
||||||
} else if (dialogTheme is! DialogThemeData) {
|
|
||||||
throw ArgumentError('dialogTheme must be either a DialogThemeData or a DialogTheme');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(QuncCccccc): Clean this up once the type of `tabBarTheme` is changed to `TabBarThemeData`
|
|
||||||
if (tabBarTheme != null) {
|
|
||||||
if (tabBarTheme is TabBarTheme) {
|
|
||||||
tabBarTheme = tabBarTheme.data;
|
|
||||||
} else if (tabBarTheme is! TabBarThemeData) {
|
|
||||||
throw ArgumentError('tabBarTheme must be either a TabBarThemeData or a TabBarTheme');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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.
|
||||||
@ -1671,12 +1616,12 @@ class ThemeData with Diagnosticable {
|
|||||||
bottomNavigationBarTheme: bottomNavigationBarTheme ?? this.bottomNavigationBarTheme,
|
bottomNavigationBarTheme: bottomNavigationBarTheme ?? this.bottomNavigationBarTheme,
|
||||||
bottomSheetTheme: bottomSheetTheme ?? this.bottomSheetTheme,
|
bottomSheetTheme: bottomSheetTheme ?? this.bottomSheetTheme,
|
||||||
buttonTheme: buttonTheme ?? this.buttonTheme,
|
buttonTheme: buttonTheme ?? this.buttonTheme,
|
||||||
cardTheme: cardTheme as CardThemeData? ?? this.cardTheme,
|
cardTheme: cardTheme ?? this.cardTheme,
|
||||||
checkboxTheme: checkboxTheme ?? this.checkboxTheme,
|
checkboxTheme: checkboxTheme ?? this.checkboxTheme,
|
||||||
chipTheme: chipTheme ?? this.chipTheme,
|
chipTheme: chipTheme ?? this.chipTheme,
|
||||||
dataTableTheme: dataTableTheme ?? this.dataTableTheme,
|
dataTableTheme: dataTableTheme ?? this.dataTableTheme,
|
||||||
datePickerTheme: datePickerTheme ?? this.datePickerTheme,
|
datePickerTheme: datePickerTheme ?? this.datePickerTheme,
|
||||||
dialogTheme: dialogTheme as DialogThemeData? ?? this.dialogTheme,
|
dialogTheme: dialogTheme ?? this.dialogTheme,
|
||||||
dividerTheme: dividerTheme ?? this.dividerTheme,
|
dividerTheme: dividerTheme ?? this.dividerTheme,
|
||||||
drawerTheme: drawerTheme ?? this.drawerTheme,
|
drawerTheme: drawerTheme ?? this.drawerTheme,
|
||||||
dropdownMenuTheme: dropdownMenuTheme ?? this.dropdownMenuTheme,
|
dropdownMenuTheme: dropdownMenuTheme ?? this.dropdownMenuTheme,
|
||||||
@ -1702,7 +1647,7 @@ class ThemeData with Diagnosticable {
|
|||||||
sliderTheme: sliderTheme ?? this.sliderTheme,
|
sliderTheme: sliderTheme ?? this.sliderTheme,
|
||||||
snackBarTheme: snackBarTheme ?? this.snackBarTheme,
|
snackBarTheme: snackBarTheme ?? this.snackBarTheme,
|
||||||
switchTheme: switchTheme ?? this.switchTheme,
|
switchTheme: switchTheme ?? this.switchTheme,
|
||||||
tabBarTheme: tabBarTheme as TabBarThemeData? ?? this.tabBarTheme,
|
tabBarTheme: tabBarTheme ?? this.tabBarTheme,
|
||||||
textButtonTheme: textButtonTheme ?? this.textButtonTheme,
|
textButtonTheme: textButtonTheme ?? this.textButtonTheme,
|
||||||
textSelectionTheme: textSelectionTheme ?? this.textSelectionTheme,
|
textSelectionTheme: textSelectionTheme ?? this.textSelectionTheme,
|
||||||
timePickerTheme: timePickerTheme ?? this.timePickerTheme,
|
timePickerTheme: timePickerTheme ?? this.timePickerTheme,
|
||||||
|
@ -545,10 +545,7 @@ void main() {
|
|||||||
StatefulBuilder(
|
StatefulBuilder(
|
||||||
builder: (BuildContext context, StateSetter stateSetter) {
|
builder: (BuildContext context, StateSetter stateSetter) {
|
||||||
setState = stateSetter;
|
setState = stateSetter;
|
||||||
return Theme(
|
return Theme(data: ThemeData(cardTheme: cardThemeData), child: const ThemedCard());
|
||||||
data: ThemeData(cardTheme: CardTheme(data: cardThemeData)),
|
|
||||||
child: const ThemedCard(),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user