Search packages, repositories and app categories

Package detailsv0.1.0

matrix_gesture_detector

A gesture detector mapping translation/rotation/scale gestures to a Matrix4 object.

30-day downloads
884
Likes
80
Pub points
25

Install package

flutter pub add matrix_gesture_detector

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter package that translates user touch gestures—such as panning, rotating, and scaling—into a Matrix4 object. It enables precise 2D transformations by mapping multi-touch inputs to a single transformation matrix, ideal for interactive graphics, canvas-based apps, or custom UI components requiring advanced gesture handling. The package simplifies the management of complex gestures by abstracting low-level touch events into a unified matrix representation.

Use cases

  • Interactive canvas manipulation
  • Image or widget scaling and rotation
  • Custom drawing tools
  • Gesture-based UI components
  • 2D transform animations

Key features

  • Maps gestures to Matrix4
  • Supports translation, rotation, and scale
  • Handles multi-touch input
  • Provides clean API for transformation logic
  • Integrates with RenderBox and CustomPaint

Suitable for

  • Developers building interactive graphics
  • Apps requiring precise 2D transforms
  • UI components with pinch-to-zoom or rotate features
  • Canvas-based drawing applications
  • Advanced gesture-driven interfaces

Considerations

  • Requires understanding of Matrix4 and 2D transforms
  • Not suitable for simple tap or swipe gestures
  • May need performance tuning for high-frequency updates
  • Limited to 2D transformations
  • No built-in animation support

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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

Categories

Dependencies

Dependency list 1 items

Source repository

Projects using this package