无法将参数类型“ MaterialColor”分配给参数类型“ Paint”

时间:2018-07-18 18:59:02

标签: android dart flutter flutter-layout

enter image description here

我想将背景色设置为红色,但是 TextStyle 小部件下没有'backgroundColor'属性。

有背景属性,但我无法设置背景值。它显示错误,错误为

  

不能将参数类型'MaterialColor'分配给该参数   输入“绘画”

我知道该错误是合理的。但是背景属性的值应该是多少?

我搜索了,但不幸的是找不到:( 我可以将背景设置为background: Paint(),背景变为黑色。但是我需要红色背景。 背景值是什么?

谢谢

2 个答案:

答案 0 :(得分:4)

只需将color的{​​{1}}属性设置为Paint

Colors.red

答案 1 :(得分:0)

我建议您不要像这样使用 User.find({ email: { $elemMatch: { types: { $elemMatch: { $in: [objectId of the certain types], }, }, }, }, }).populate({ path: 'emails', populate: { path: 'types', }, }); 属性来直接使用background属性:

backgroundColor
相关问题