Output Screenshot:
SOLUTION
Color getColor(number) {
if (number > 0 && number < 100) return Colors.red;
if (number >= 100 && number < 200) return Colors.blue;
...
}
color: getColor(item),
Color textColor = Colors.black; // Default color
TextStyle(
fontWeight: FontWeight.bold,
color: textColor,
),
FlatButton(
onPressed: () {
setState(() => textColor =
Color((Random().nextDouble() * 0xFFFFFF).toInt() << 0)
.withOpacity(1.0)); // this is generate random color, u can use your own..
},
child: Text("change color"),
),
Full Summary:
Refrence
Click here
Top comments (0)