搜索插件、代码仓与 APP 分类

插件详情v0.1.0

matrix_gesture_detector

一个将平移/旋转/缩放手势映射到 Matrix4 对象的触摸检测器。

近 30 天下载
884
喜欢数
80
Pub 分数
25

安装插件

flutter pub add matrix_gesture_detector

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,可将用户触摸手势(如平移、旋转和缩放)转换为 Matrix4 对象。它通过将多点触控输入映射到单一变换矩阵,实现精确的 2D 变换,非常适合交互式图形、基于画布的应用程序或需要高级手势处理的自定义 UI 组件。该包通过将底层触摸事件抽象为统一的矩阵表示,简化了复杂手势的管理。

适合场景

  • 交互式画布操作
  • 图像或小部件缩放和旋转
  • 自定义绘图工具
  • 基于手势的用户界面组件
  • 2D 变换动画

主要特点

  • 将手势映射到 Matrix4
  • 支持翻译、旋转和缩放
  • 支持多点触控输入
  • 为转换逻辑提供干净的 API
  • 与 RenderBox 和 CustomPaint 集成

适合对象

  • 开发交互式图形的开发者
  • 需要精确2D变换的应用
  • 具有捏合缩放或旋转功能的 UI 组件
  • 基于画布的绘图应用
  • 高级手势驱动界面

使用建议

  • 需要理解 Matrix4 和 2D 变换
  • 不适用于简单的点击或滑动手势
  • 高频更新可能需要性能调优
  • 限制为2D变换
  • 无内置动画支持

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

matrix_gesture_detector

MatrixGestureDetector detects translation, scale and rotation gestures and combines them into Matrix4 object that can be used by Transform widget or by low level CustomPainter code. You can customize types of reported gestures by passing shouldTranslate, shouldScale and shouldRotate parameters.

Getting Started

The usage is as follows:

  MatrixGestureDetector(
    onMatrixUpdate: (Matrix4 m, Matrix4 tm, Matrix4 sm, Matrix4 rm) {
      setState(() {
        matrix = m;
      });
    },
    child: SomeWidgetThatUsesMatrix(
      matrix: matrix,
      ...
    )
  )

here: SomeWidgetThatUsesMatrix could be a Transform widget (transform_demo.dart) or a CustomPaint widget which CustomPainter uses Matrix4 in its low level drawing code (custom_painter_demo.dart).

Examples

bounded demo gif grid rotation demo gif blur demo gif

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目