弃用 `ThemeData.dialogBackgroundColor`,改用 `DialogThemeData.backgroundColor`
概述
#`ThemeData.dialogBackgroundColor` 参数已被弃用,改用 `DialogThemeData.backgroundColor` 参数。
背景
#`Dialog` 和 `AlertDialog` 小部件的默认值可以使用组件特定的主题(如 `DialogThemeData`)进行覆盖。以前,`ThemeData.dialogBackgroundColor` 参数用于覆盖默认对话框背景颜色,但由于 `DialogThemeData` 的出现而变得多余。
变更说明
#`ThemeData.dialogBackgroundColor` 已被弃用,改用组件特定的主题。使用 `DialogThemeData` 来覆盖默认背景颜色。
迁移指南
#将 `ThemeData.dialogBackgroundColor` 替换为 `DialogThemeData.backgroundColor` 以覆盖默认对话框背景颜色。
迁移前的代码
dart
theme: ThemeData(
dialogBackgroundColor: Colors.orange,
),
迁移后的代码
dart
theme: ThemeData(
dialogTheme: const DialogThemeData(backgroundColor: Colors.orange),
),
时间线
#已在版本中发布: 3.28.0-0.1.pre
稳定版发布于: 3.29
参考资料
#API 文档
相关问题
相关 PR