I am trying to change the color below from red to green if the value of a variable is more than 10. How would I do that? as 'color:' does not accept if, else statements:
Card(
child: Column(
children:[
Text('Calls Taken',
style: TextStyle(
fontSize: 16.0,
decoration: TextDecoration.underline,
),),
Text('10'),
],
),
color: Colors.redAccent
),
The above card widget is under a class that inherits StatelfulWidgets
Thank you in advance!!!
Just use a ternary if
color: variable > 10 ? Colors.redAccent : Colors.green
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With