我很少用三元的。我想要点提示。
基本上,如果选择的颜色是绿色,我想显示a+,如果选择的颜色是红色,则显示a+。
这是我的密码
Text(
[ternary] + number[math.Random().nextInt(number.length - 1)] + "%",
style: TextStyle(
color: predefinedColors[math.Random().nextInt(predefinedColors.length)],
fontSize: 10.0,
fontWeight: FontWeight.bold),
)我所用的清单
List predefinedColors = [
Colors.red,
Colors.green,
];预先感谢您的帮助
发布于 2022-05-17 14:00:22
Widget build(BuildContext context) {
return SliverToBoxAdapter(
child: SizedBox(
height: 139.0,
child: ListView.builder(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemCount: 25,
itemBuilder: (BuildContext context, int position) {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Card(
color:
Color((math.Random().nextDouble() * 0xFFFFFF).toInt())
.withOpacity(1.0),
child: const SizedBox(
width: 80,
height: 80,
),
),
Padding(
padding: const EdgeInsets.only(right: 42),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
names[math.Random().nextInt(names.length - 1)],
style: const TextStyle(
color: Colors.white,
fontSize: 10.0,
fontWeight: FontWeight.bold),
),
Text(
number[math.Random().nextInt(number.length - 1)] +
"€",
style: const TextStyle(
color: Colors.white,
fontSize: 10.0,
fontWeight: FontWeight.bold),
),
Text(
number[math.Random().nextInt(number.length - 1)] +
"%",
style: TextStyle(
color: predefinedColors[math.Random()
.nextInt(predefinedColors.length)],
fontSize: 10.0,
fontWeight: FontWeight.bold),
)
]),
),
],
);
})),
);
}https://stackoverflow.com/questions/72274675
复制相似问题