# Material Theme System Updates

> `CardTheme`, `DialogTheme`, and `TabBarTheme` have been normalized to follow Flutter's convention for component themes in the Material library. In `ThemeData`, the type of these properties have also changed accordingly.




:::important
These breaking change docs are accurate, as of the release
under which they are published. Over time, the
workarounds described here might become inaccurate.
We don't, in general, keep these breaking change docs up
to date as of each release.

这些破坏性改动文档的准确性仅限于其发布时对应的版本。
随着时间的推移，文档中描述的方案可能会逐渐失效。
通常情况下，我们不会在每次发布新版本时都对这些文档进行同步更新。

The [breaking change index file](/release/breaking-changes)
lists the docs created for each release.

[破坏性改动列表](/release/breaking-changes) 
列出了每个版本的文档。

:::


## Summary

`CardTheme`, `DialogTheme` and `TabBarTheme` were refactored to
conform to Flutter's conventions for component themes. `CardThemeData`,
`DialogThemeData` and `TabBarThemeData` were added to define overrides for the
defaults of the component visual properties.

During card theme normalization, the type of `ThemeData.cardTheme` is changed
to `Object?` to accept both `CardTheme` and `CardThemeData`, in order to have
a smooth transition for the breaking changes. The same approach was used for
`dialogTheme` and `tabBarTheme`.

To complete the transition and fully conform to the `ThemeData` convention, the
type of `ThemeData.cardTheme` has been changed to `CardThemeData?`; the type of
`ThemeData.dialogTheme` has been changed to `DialogThemeData?`; and the type of
`ThemeData.tabBarTheme` has been changed to `TabBarThemeData?`.

## Migration guide

Previously, the type of `ThemeData.cardTheme` was `Object?` to accept both
`CardTheme` and `CardThemeData`. Now that the type has been changed to
`CardThemeData?`, a migration is required if `ThemeData.cardTheme` is used.
Similarly, the types of `ThemeData.dialogTheme` and `ThemeData.tabBarTheme`
should be migrated to `DialogThemeData` and `TabBarThemeData`, respectively.

Code before migration:

```dart
final ThemeData theme = ThemeData(
    cardTheme: CardTheme(),
    dialogTheme: DialogTheme(),
    tabBarTheme: TabBarTheme(),
);
```

Code after migration:

```dart
final ThemeData theme = ThemeData(
    cardTheme: CardThemeData(),
    dialogTheme: DialogThemeData(),
    tabBarTheme: TabBarThemeData(),
);
```

## Timeline

Landed in version: 3.31.0-0.0.pre<br>
In stable release: 3.32

## References

API documentation:

* [`ThemeData`][]
* [`CardTheme`][]
* [`DialogTheme`][]
* [`TabBarTheme`][]

Relevant PRs:

* [Change cardTheme, dialogTheme, and tabBarTheme type to xxxThemeData][]

[Change cardTheme, dialogTheme, and tabBarTheme type to xxxThemeData]: https://github.com/flutter/flutter/pull/157292
[`ThemeData`]: https://api.flutter-io.cn/flutter/material/ThemeData-class.html
[`CardTheme`]: https://api.flutter-io.cn/flutter/material/CardTheme-class.html
[`DialogTheme`]: https://api.flutter-io.cn/flutter/material/DialogTheme-class.html
[`TabBarTheme`]: https://api.flutter-io.cn/flutter/material/TabBarTheme-class.html

