Home > Enterprise >  How can i make the icon change when it is clicked
How can i make the icon change when it is clicked

Time:10-27

I want the arrow to change and display the visibility widget when about me is clicked on the image.

CodePudding user response:

 int angle = 0; 
 RotatedBox(
          quarterTurns: angle,
          child: IconButton(
            icon: Icon(Icons.arrow_forward_ios),
            onPressed: () {
              setState(() {
                angle = 1;
              });
            },
          ),
        ),

CodePudding user response:

About your attached image, you can simply get the effect using ExpansionTile.

How-ever to change icon based on click

  • create a bool _isExpanded = false inside state class.
  • On expand changes, use setstate to change the value. Using assigning the icon
Icon(_isExpanded?
          Icons.arrow_downward
          :Icons.arrow_upward,
          ),
  • Related