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 accpet 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: TBD Stable release: TBD
References
#API documentation:
Relevant PRs:
除非另有说明,本文档之所提及适用于 Flutter 的最新稳定版本,本页面最后更新时间: 2025-02-11。 查看文档源码 或者 为本页面内容提出建议。