flutter中有三中方式添加点击事件
InkWell
InkWell(
child: buildButtonColum(Icons.call, 'CALL'),
onTap:(){
print('单击');
},
onDoubleTap: () {
// 双击
},
onLongPress: () {
// 长按
}
),
GestureDetector
_onClick(){
}
@override
Widget build(BuildContext context) {
// TODO: implement build
return Container(
child: GestureDetector(
onTap: _onClick,//写入方法名称就可以了,但是是无参的
child: Text("dianji"),
),
);
}
RaisedButton
@override
Widget build(BuildContext context) {
return RaisedButton(
elevation: 0,
focusElevation: 0,//这两行设置无阴影
disabledColor: Colors.white,//无法点击时的背景色
color: Colors.white,//正常状态下的背景色
onPressed: () {
print("click");
},
child: Text("Button"),
);
}