flutter - 口音颜色已弃用颤振 2.5
问题描述
我使用accentColor
属性,我知道这个属性已被弃用。如何使用新方法创建特定的强调色?
代码是:
theme: ThemeData(
accentColor: const Color(accentColor),
),
解决方案
用这个
theme: ThemeData(
colorScheme: Theme.of(context).colorScheme.copyWith(secondary: Color(accentColor))
),
有关更多信息,请查看他们的文档
https://flutter.dev/docs/release/break-changes/theme-data-accent-properties
final ThemeData theme = ThemeData();
MaterialApp(
theme: theme.copyWith(
colorScheme: theme.colorScheme.copyWith(secondary: myColor),
),
//...
)
迁移前的代码:
Color myColor = Theme.of(context).accentColor;
迁移后的代码:
Color myColor = Theme.of(context).colorScheme.secondary;
推荐阅读
- java - Android Studio 是否以某种方式缓存 Firebase 数据?
- r - ggplot2,线型与 aes 映射中指定的不匹配
- html - Bootstrap 4 表(改变垂直填充/间距?)
- python - 从 numpy 距离矩阵有效地生成 JSON 摘要
- gulp - BrowserSync 错误:“您尝试启动 BrowserSync 两次”
- python - NameError 与类变量
- ubuntu-14.04 - 无法在 Ubuntu 14.04 中安装软件包
- php - 如何在 PHP 中使用 HTML 作为模板?
- sql - Spring Data:Native Query,映射到自定义 Bean,别名列;不使用投影)
- border - 如何在CGAL中找到SurfaceMesh最长边界上的顶点