Material Theme System Updates
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:
final ThemeData theme = ThemeData(
cardTheme: CardTheme(),
dialogTheme: DialogTheme(),
tabBarTheme: TabBarTheme(),
);
Code after migration:
final ThemeData theme = ThemeData(
cardTheme: CardThemeData(),
dialogTheme: DialogThemeData(),
tabBarTheme: TabBarThemeData(),
);
Timeline
#
Landed in version: 3.31.0-0.0.pre
In stable release: 3.32
References
#API documentation:
Relevant PRs:
Unless stated otherwise, the documentation on this site reflects Flutter 3.38.0. Page last updated on 2025-10-30. View source or report an issue.