背景
组件手势检测,单击、双击、长按、松开、移动、横向拖动、竖向拖动等事件
属性 | 作用 |
---|---|
onTap | 单击 |
onDoubleTap | 双击 |
onLongPress | 长按 |
onPanUpdate | 拖动实时更新 |
onHorizontalDragDown | 横向点击 |
onVerticalDragDown | 竖向点击 |
GestureDetector(
onTap: () => setState(() => _info = 'onTap'),
onDoubleTap: () => setState(() => _info = 'onDoubleTap'),
onLongPress: () => setState(() => _info = 'onLongPress'),
onHorizontalDragDown: (detail) => setState(() {
detail.globalPosition;
detail.localPosition;
}),
child: Container(
alignment: Alignment.center,
width: 300,
height: 300 * 0.4,
color: Colors.grey.withAlpha(33),
child: Text(
_info,
style: const TextStyle(fontSize: 18, color: Colors.blue),
),
),
)