criei um widget e instanciei ele no TaskState
class ColorContainer extends StatelessWidget {
ColorContainer({super.key, required this.nivel});
final int nivel;
final List<Color> listColors = [
Colors.blue,
Colors.yellow,
Colors.green,
Colors.red,
Colors.black
];
@override
Widget build(BuildContext context) {
final index = (nivel - 1) ~/ 10;
final color = listColors[index.clamp(0, listColors.length - 1)];
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5),
color: color,
),
height: 140,
);
}
}