@@ -315,7 +315,8 @@ class ThemeData with Diagnosticable {
315315 BottomNavigationBarThemeData ? bottomNavigationBarTheme,
316316 BottomSheetThemeData ? bottomSheetTheme,
317317 ButtonThemeData ? buttonTheme,
318- CardTheme ? cardTheme,
318+ // TODO(QuncCccccc): Change the parameter type to CardThemeData
319+ Object ? cardTheme,
319320 CheckboxThemeData ? checkboxTheme,
320321 ChipThemeData ? chipTheme,
321322 DataTableThemeData ? dataTableTheme,
@@ -493,7 +494,15 @@ class ThemeData with Diagnosticable {
493494 bottomAppBarTheme ?? = const BottomAppBarTheme ();
494495 bottomNavigationBarTheme ?? = const BottomNavigationBarThemeData ();
495496 bottomSheetTheme ?? = const BottomSheetThemeData ();
496- cardTheme ?? = const CardTheme ();
497+ // TODO(QuncCccccc): Clean it up once the type of `cardTheme` is changed to `CardThemeData`
498+ if (cardTheme != null ) {
499+ if (cardTheme is CardTheme ) {
500+ cardTheme = cardTheme.data;
501+ } else if (cardTheme is ! CardThemeData ) {
502+ throw ArgumentError ('cardTheme must be either a CardThemeData or a CardTheme' );
503+ }
504+ }
505+ cardTheme ?? = const CardThemeData ();
497506 checkboxTheme ?? = const CheckboxThemeData ();
498507 chipTheme ?? = const ChipThemeData ();
499508 dataTableTheme ?? = const DataTableThemeData ();
@@ -594,7 +603,7 @@ class ThemeData with Diagnosticable {
594603 bottomNavigationBarTheme: bottomNavigationBarTheme,
595604 bottomSheetTheme: bottomSheetTheme,
596605 buttonTheme: buttonTheme,
597- cardTheme: cardTheme,
606+ cardTheme: cardTheme as CardThemeData ,
598607 checkboxTheme: checkboxTheme,
599608 chipTheme: chipTheme,
600609 dataTableTheme: dataTableTheme,
@@ -1266,7 +1275,7 @@ class ThemeData with Diagnosticable {
12661275 /// The colors and styles used to render [Card] .
12671276 ///
12681277 /// This is the value returned from [CardTheme.of] .
1269- final CardTheme cardTheme;
1278+ final CardThemeData cardTheme;
12701279
12711280 /// A theme for customizing the appearance and layout of [Checkbox] widgets.
12721281 final CheckboxThemeData checkboxTheme;
@@ -1466,7 +1475,7 @@ class ThemeData with Diagnosticable {
14661475 BottomNavigationBarThemeData ? bottomNavigationBarTheme,
14671476 BottomSheetThemeData ? bottomSheetTheme,
14681477 ButtonThemeData ? buttonTheme,
1469- CardTheme ? cardTheme,
1478+ Object ? cardTheme,
14701479 CheckboxThemeData ? checkboxTheme,
14711480 ChipThemeData ? chipTheme,
14721481 DataTableThemeData ? dataTableTheme,
@@ -1521,6 +1530,15 @@ class ThemeData with Diagnosticable {
15211530 }) {
15221531 cupertinoOverrideTheme = cupertinoOverrideTheme? .noDefault ();
15231532
1533+ // TODO(QuncCccccc): Clean it up once the type of `cardTheme` is changed to `CardThemeData`
1534+ if (cardTheme != null ) {
1535+ if (cardTheme is CardTheme ) {
1536+ cardTheme = cardTheme.data;
1537+ } else if (cardTheme is ! CardThemeData ) {
1538+ throw ArgumentError ('cardTheme must be either a CardThemeData or a CardTheme' );
1539+ }
1540+ }
1541+
15241542 // TODO(QuncCccccc): Clean this up once the type of `dialogTheme` is changed to `DialogThemeData`
15251543 if (dialogTheme != null ) {
15261544 if (dialogTheme is DialogTheme ) {
@@ -1585,7 +1603,7 @@ class ThemeData with Diagnosticable {
15851603 bottomNavigationBarTheme: bottomNavigationBarTheme ?? this .bottomNavigationBarTheme,
15861604 bottomSheetTheme: bottomSheetTheme ?? this .bottomSheetTheme,
15871605 buttonTheme: buttonTheme ?? this .buttonTheme,
1588- cardTheme: cardTheme ?? this .cardTheme,
1606+ cardTheme: cardTheme as CardThemeData ? ?? this .cardTheme,
15891607 checkboxTheme: checkboxTheme ?? this .checkboxTheme,
15901608 chipTheme: chipTheme ?? this .chipTheme,
15911609 dataTableTheme: dataTableTheme ?? this .dataTableTheme,
@@ -1778,7 +1796,7 @@ class ThemeData with Diagnosticable {
17781796 bottomNavigationBarTheme: BottomNavigationBarThemeData .lerp (a.bottomNavigationBarTheme, b.bottomNavigationBarTheme, t),
17791797 bottomSheetTheme: BottomSheetThemeData .lerp (a.bottomSheetTheme, b.bottomSheetTheme, t)! ,
17801798 buttonTheme: t < 0.5 ? a.buttonTheme : b.buttonTheme,
1781- cardTheme: CardTheme .lerp (a.cardTheme, b.cardTheme, t),
1799+ cardTheme: CardThemeData .lerp (a.cardTheme, b.cardTheme, t),
17821800 checkboxTheme: CheckboxThemeData .lerp (a.checkboxTheme, b.checkboxTheme, t),
17831801 chipTheme: ChipThemeData .lerp (a.chipTheme, b.chipTheme, t)! ,
17841802 dataTableTheme: DataTableThemeData .lerp (a.dataTableTheme, b.dataTableTheme, t),
@@ -2076,7 +2094,7 @@ class ThemeData with Diagnosticable {
20762094 properties.add (DiagnosticsProperty <BottomNavigationBarThemeData >('bottomNavigationBarTheme' , bottomNavigationBarTheme, defaultValue: defaultData.bottomNavigationBarTheme, level: DiagnosticLevel .debug));
20772095 properties.add (DiagnosticsProperty <BottomSheetThemeData >('bottomSheetTheme' , bottomSheetTheme, defaultValue: defaultData.bottomSheetTheme, level: DiagnosticLevel .debug));
20782096 properties.add (DiagnosticsProperty <ButtonThemeData >('buttonTheme' , buttonTheme, level: DiagnosticLevel .debug));
2079- properties.add (DiagnosticsProperty <CardTheme >('cardTheme' , cardTheme, level: DiagnosticLevel .debug));
2097+ properties.add (DiagnosticsProperty <CardThemeData >('cardTheme' , cardTheme, level: DiagnosticLevel .debug));
20802098 properties.add (DiagnosticsProperty <CheckboxThemeData >('checkboxTheme' , checkboxTheme, defaultValue: defaultData.checkboxTheme, level: DiagnosticLevel .debug));
20812099 properties.add (DiagnosticsProperty <ChipThemeData >('chipTheme' , chipTheme, level: DiagnosticLevel .debug));
20822100 properties.add (DiagnosticsProperty <DataTableThemeData >('dataTableTheme' , dataTableTheme, defaultValue: defaultData.dataTableTheme, level: DiagnosticLevel .debug));
0 commit comments