There are many button components in Flutter. The common button components are: RaisedButton
(button), MaterialButton
(button), ( DropDownButton
button), 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 Inkwell
and MaterialButton
, and I feel that Inkwell
all layouts can be realized, and they are basically used Inkwell
. Here is a record of the problems encountered:
1. Inkwell cancels the water ripple
Inkwell
When 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 IgnorePointer
or AbsorbPointer
wrap 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(
"点击无效",
),
),
),
);