1

I would like that when a variable is = true the icon would be a color, but if it was = false it would be another.Any idea how I can do that in flutter?

2 Answers 2

2

Since you have not specified, I'm going to use the container widget as an example.

bool colorChange = false;
Container(
 color: colorChange? Colors.blue : Colors.red,
  
)

This will work for sure.

Sign up to request clarification or add additional context in comments.

Comments

2

try this,

 Icon(
      Icons.widgets,
      color: (your boolean value goes here)? Colors.blue : Colors.amber,
 ),

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.