我想使用GestureDetector
的LongPressDown
函数,它还提供了LongPressDownDetails
,但不幸的是,Gesture Detector没有涟漪触摸效果。因此,如果我选择使用InkWell
,它就没有LongPressDownDetails
。
所以我的问题是,如何在具有GestureDetector功能的同时获得InkWell的涟漪效果?
我想使用GestureDetector
的LongPressDown
函数,它还提供了LongPressDownDetails
,但不幸的是,Gesture Detector没有涟漪触摸效果。因此,如果我选择使用InkWell
,它就没有LongPressDownDetails
。
所以我的问题是,如何在具有GestureDetector功能的同时获得InkWell的涟漪效果?
很简单,只需在 GestureDetector
上添加一个 Inkwell
,你就可以开始使用了(无需在 onTap
中编写任何内容)。
return InkWell(
onTap: () {},
child: GestureDetector(
onLongPress: (){
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: Text('Tap'),
));
}
,
child: const Padding(
padding: EdgeInsets.all(12.0),
child: Text('Flat Button'),
),
),
);