android - 参数类型 'Color?' 不能分配给参数类型 'MaterialColor?

标签 android visual-studio flutter dart

enter image description here
我想在 flutter 中设置背景 Colors.yellow[700],但是当我添加符号“[]”或 Colors.yellow.shade600 时,我无法设置背景的值。它显示错误并且错误是

The argument type 'MaterialColor' can't be assigned to the parameter type 'Paint'

最佳答案

您也可以使用 colorScheme属性并设置如下:

theme: ThemeData(
    colorScheme: ColorScheme.fromSwatch().copyWith(

      primary: const Colors.yellow[700],
      secondary: const Colors.yellow.shade700,

      // or from RGB

      primary: const Color(0xFF343A40),
      secondary: const Color(0xFFFFC107),

    ),
  ),

关于android - 参数类型 'Color?' 不能分配给参数类型 'MaterialColor?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67930143/

相关文章:

android - 在 x86 中为 android 平台构建 openh264

c++ - Visual Studio 2010转换2005解决方案(C++项目)丢失项目依赖

firebase - Flutter Firebase 远程配置类中没有虚拟方法 isDeveloperModeEnabled()Z .../FirebaseRemoteConfigSettings

flutter - Flutter:导入和库之间的区别

android - 如何自动调整 TextView 中的文本大小以适应垂直和水平可用空间?

android - Google Maps V2 - Android - 获取标记列表

android - PendingIntent 与 IntentService 不起作用

asp.net - 任务运行程序资源管理器 ASP.NET - 在严格模式之外尚不支持 block 范围声明

xml - 递归使用 XSD

flutter - Dart |无需计算即可将秒数转换为 DateTime