itemBuilder: (BuildContext context,int index) {
Color color;
switch (index % 10) {
case 0:
color = Colors.red;
break;
case 1:
color = Colors.blue;
break;
... // and so on,up to 9
default:
color = Colors.black;
}
return Container(
color: color,child: ListTile(
title: ...
),);
},
,
这就是我所说的随机颜色:
Color((math.Random().nextDouble() * 0xFFFFFF).toInt() << 0)
.withOpacity(1.0);
在您的情况下:
Color(index << 0).withOpacity(1.0);
,
child: Container(
width: 100,height: 100,color: index % 4 == 0
? Colors.green
: index % 4 == 1
? Colors.amber
: index % 4 == 2
? Colors.pink
: Colors.lime,)
如果梯形图也在同一行中寻找开关箱,那么如果您真的想单行执行此操作,则这样
本文链接:https://www.f2er.com/3147941.html