how to change icon color immediately after pressed in flutter?
You can simply put a condition for each color :
color:(isPressed) ? Color(0xff007397)
: Color(0xff9A9A9A))
and in the onPressed function :
onPressed: ()
{
setState(()
{
isPressed= true;
});
}
You need to use setState() function. Wherever you are updating your variable values.
For example, I want to update my _newVar value to newValue and this should be updated into the view then instead of writing
_newVar = newValue;
it should be:
setState(() {
_newVar = newValue;
});