Home > OS >  How to change the animation of pressing and long pressing in IconButton
How to change the animation of pressing and long pressing in IconButton

Time:10-05

By default, the IconButton has a circular outline with a specified radius when you click on it, how can I change this and make it according to the office of my container?

Container(
  color: Colors.lightBlueAccent,
    child: IconButton(
      icon:  Icon( Icons.settings,),
      iconSize: 100,
      onPressed: () {},), 
          ),

enter image description here

CodePudding user response:

My suggestion is instead of using IconButton, use GestureDetector. Create GestureDetector with Icon as a child. You can set onLongTap, onTap, and many more.

CodePudding user response:

The splash radius of IconButton is default to Material.defaultSplashRadius, which is 35. You can simply change the splash radius of IconButton like this

Container(
        color: Colors.lightBlueAccent,
        child: IconButton(
          // Note: splashRadius cannot be set to 0
          splashRadius: 0.1,
          icon: Icon(
            Icons.settings,
          ),
          iconSize: 100,
          onPressed: () {},
        ),
      ),
  • Related