Animation effect of Flutter cancel button

There are many button components in Flutter. The common button components are: RaisedButton(button), MaterialButton(button), ( DropDownButtonbutton), FlatButton(flat button), IconButton(icon button), 弹出菜单按钮(popup menu button), OutlineButton(outline button), ButtonBar(outline button), FloatingActionButton(floating button), Inkwell(ink button), etc. In actual project development, you can choose your favorite controls according to your needs or habits.

The most commonly used ones are Inkwelland MaterialButton, and I feel that Inkwellall layouts can be realized, and they are basically used Inkwell. Here is a record of the problems encountered:

1. Inkwell cancels the water ripple

InkwellWhen you click, there will be an animation effect like water ripples, but sometimes it looks abrupt, you need to cancel this effect, just add the following two properties.

highlightColor: Colors.transparent,
radius: 0.0,

2. The setting of MaterialButton cannot be clicked or invalidated.

Use IgnorePointeror AbsorbPointerwrap the button and set the properties ignoring.

return IgnorePointer(
    ignoring: true,// false无效
    child: MaterialButton(
        elevation: 0,
        shape: const RoundedRectangleBorder(
          borderRadius: BorderRadius.all(
            Radius.circular(8),
          ),
        ),
        onPressed: () {
        },
        child: const Align(
          alignment: Alignment.center,
          child: Text(
            "点击无效",
          ),
        ),
      ),
    );

Guess you like

Origin blog.csdn.net/king6188/article/details/131572685