how to change icon color immediately after pressed in flutter?

前端 未结 2 1726
刺人心
刺人心 2021-01-18 00:49

I would like to change the color of an icon after pressing it, but it seems the following code doesn\'t work.

  void actionClickRow(String key) {
    Navigat         


        
2条回答
  •  一整个雨季
    2021-01-18 01:42

    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;
    });
    

提交回复
热议问题