Component theme normalization
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.
Releases of Flutter continue to normalize component themes like these for
a more consistent theming experience in the material library.
Migration guide
#In ThemeData
:
- The type of the
cardTheme
property has been changed fromCardTheme
toCardThemeData
. - The type of the
dialogTheme
property has been changed from theDialogTheme
toDialogThemeData
. - The type of
tabBarTheme
property has been changed fromTabBarTheme
toTabBarThemeData
.
The return type of the component theme xTheme.of()
methods and
Theme.of().xTheme
have also changed to xThemeData
accordingly.
Code before migration:
final CardTheme cardTheme = Theme.of(context).cardTheme;
final CardTheme cardTheme = CardTheme.of(context);
final DialogTheme dialogTheme = Theme.of(context).dialogTheme;
final DialogTheme dialogTheme = DialogTheme.of(context);
final TabBarTheme tabBarTheme = Theme.of(context).tabBarTheme;
final TabBarTheme tabBarTheme = TabBarTheme.of(context);
Code after migration:
final CardThemeData cardTheme = Theme.of(context).cardTheme;
final CardThemeData cardTheme = CardTheme.of(context);
final DialogThemeData dialogTheme = Theme.of(context).dialogTheme;
final DialogThemeData dialogTheme = DialogTheme.of(context);
final TabBarThemeData tabBarTheme = Theme.of(context).tabBarTheme;
final TabBarThemeData tabBarTheme = TabBarTheme.of(context);
Timeline
#Landed in version: 3.27.0-0.0.pre
Stable release: 3.27
References
#API documentation:
Relevant PRs:
除非另有说明,本文档之所提及适用于 Flutter 的最新稳定版本,本页面最后更新时间: 2024-12-16。 查看文档源码 或者 为本页面内容提出建议。