touchable
1.0.2, released 5 years ago by an unverified publisher
Add gesture callbacks and interactivity to shapes drawn inside a Flutter CustomPainter canvas.
What it does
It wraps a CustomPaint widget and provides a TouchyCanvas that tracks shape dimensions, painting styles, stroke widths, and clipping regions. When a user interacts with the canvas, it automatically detects which shape was touched and fires the corresponding callback.
AI-written summary of version 1.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are building custom drawings using a CustomPainter and need touch interactions for individual shapes
- You want to handle tap, pan, or other gesture events on custom canvas drawings easily
Skip it when
- You are building standard UI layouts where standard Flutter widgets like GestureDetector and containers suffice
- You need advanced touch detection on complex vertices that are not yet supported by the roadmap
Strengths
- Supports multiple gesture callbacks per shape
- Automatically handles paint style, stroke width, and clipping modes
- Simple and intuitive API utilizing CanvasTouchDetector and TouchyCanvas
Weaknesses
- Custom Path hit testing is currently limited to opaque hit test behavior
- Missing support for translation, rotation, scaling, and skewing transformations
- Not running touch detection in a separate isolate yet
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
No native configuration or build_runner required; just add the dependency to pubspec.yaml.
CanvasTouchDetector(
builder: (context) =>
CustomPaint(
painter: MyPainter(context)
)
)Alternatives
Packages that do the same job and could replace touchable.
- morphable_shape
Create responsive shapes and morph between them in Flutter.
83Compare - flutter_painter
A Flutter widget for drawing scribbles, text, shapes and images on a canvas.
74Compare - material_new_shapes
Provides Material 3 shape definitions (e.g., RoundedPolygon, Cubic) for Flutter UI.
48Compare - patterns_canvas
Draw patterns like stripes, dots, or checkers on Canvas elements or widgets in Flutter.
64Compare
Works with
Packages commonly used together with touchable: ones it builds on, ones built on it, and its own family.