List<int>
[0,255,255]。我怎么做?
List<int> getRGB(Color c) {
return [c.red, c.blue, c.green];
}
使用
Color c = Colors.red;
print(getRGB(c));
使用返回分数值(从0到1)的
.r
,.g
属性。将它们乘以255和圆,以获取整数RGB值。
List<int> getRGB(Color c) {
return [
(c.r * 255).round(),
(c.b * 255).round(),
(c.g * 255).round(),
];
}
这种方法替换了dop的dofected用法,.blue
,.red
,
.green
。
https://api.flutter.dev/flutter/dart-ui/color-class.html