Flutter——最详细(GestureDetector)使用教程

背景

组件手势检测,单击、双击、长按、松开、移动、横向拖动、竖向拖动等事件

属性 作用
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),
        ),
      ),
    )

相关推荐

  1. Flutter——详细(GestureDetector)使用教程

    2024-07-11 02:02:03       24 阅读
  2. flutter学习-day22-使用GestureDetector识别手势事件

    2024-07-11 02:02:03       43 阅读
  3. Flutter】webview_flutter使用详解

    2024-07-11 02:02:03       39 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-11 02:02:03       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-11 02:02:03       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-11 02:02:03       58 阅读
  4. Python语言-面向对象

    2024-07-11 02:02:03       69 阅读

热门阅读

  1. Jenkins构建python项目

    2024-07-11 02:02:03       20 阅读
  2. 使用nodejs进行截图

    2024-07-11 02:02:03       19 阅读
  3. nginx部署vue项目

    2024-07-11 02:02:03       24 阅读
  4. 【网络】SCTP协议概念

    2024-07-11 02:02:03       27 阅读
  5. Git 完整的提交规范教程

    2024-07-11 02:02:03       21 阅读
  6. 【Zoom安全解析】深入Zoom的端到端加密机制

    2024-07-11 02:02:03       23 阅读
  7. Qt QSettings 使用详解:跨平台的配置管理

    2024-07-11 02:02:03       19 阅读
  8. Docker Dockerfile:构建与优化

    2024-07-11 02:02:03       23 阅读
  9. 面试题07-09

    2024-07-11 02:02:03       22 阅读
  10. docker里日志分割的方法

    2024-07-11 02:02:03       23 阅读
  11. C#面:解释startup class的configure方法有什么作用?

    2024-07-11 02:02:03       25 阅读