Package selection guidance compiled from public package information, community data, and project usage.
Draw_Your_Image is a Flutter package that allows users to draw directly on a custom UI using their fingers or stylus. It provides a simple, interactive canvas for sketching, painting, or signing within apps. Ideal for creative tools, note-taking apps, or digital signature capture, it supports multiple platforms including mobile, web, and desktop. The package integrates smoothly with Flutter’s widget system and offers customizable brush settings. It is open-source and maintained by a dedicated developer.
Use cases
Digital sketching
Signature capture
Interactive whiteboards
Educational drawing apps
Creative design tools
Key features
Touch-based drawing
Customizable brush size and color
Cross-platform support
Simple integration with Flutter
Open-source codebase
Suitable for
App developers building creative tools
Educators creating interactive learning apps
Apps requiring user signatures
Designers needing drawing features
Prototyping interactive interfaces
Considerations
Performance may vary on low-end devices
Limited advanced editing tools
No built-in export functionality
Requires manual handling of save/load logic
Brush customization options are basic
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
draw_your_image
A Flutter package for creating customizable drawing canvases with a declarative API.
Core Concept
Fully declarative, fully customizable
No controllers required - Manage stroke data in your widget state
Customize everything - Control stroke behavior through simple callbacks
Bring your own features - Implement undo/redo, zoom/pan, image export as your app needs
This package focuses on providing a flexible drawing widget, leaving app-specific features to you.
Features
✨ Device-aware drawing - Distinguish between stylus, finger, and mouse input
🎨 Flexible stroke handling - Customize behavior per input device or any other criteria
🖌️ Built-in smoothing - Catmull-Rom spline interpolation included
⚙️ Fully customizable - Colors, widths, smoothing algorithms
🔍 Intersection detection - Customizable stroke overlap detection
Quick Start
classMyDrawingPageextendsStatefulWidget{
@override_MyDrawingPageStatecreateState() => _MyDrawingPageState();
}
class_MyDrawingPageStateextendsState<MyDrawingPage> {
/// Store all the strokes on app side as stateList<Stroke> _strokes = [];
@overrideWidgetbuild(BuildContext context) {
returnDraw(
strokes: _strokes, // pass strokes via
onStrokeDrawn: (stroke) {
// store new drawn stroke and rebuildsetState(() {
_strokes = [..._strokes, stroke];
});
},
);
}
}
That's it! The canvas accepts any input and draws with default settings.
Device-Aware Drawing with onStrokeStarted
The onStrokeStarted callback lets you control stroke behavior based on input devices or any other criteria.
classStrokePoint{
finalOffset position; // Position of the pointfinaldouble pressure; // Raw pressure (0.0 to 1.0+)finaldouble pressureMin; // Minimum pressure for this devicefinaldouble pressureMax; // Maximum pressure for this devicefinaldouble tilt; // Stylus tilt angle (0 to π/2 radians)finaldouble orientation; // Stylus orientation (-π to π radians)// Normalized pressure getter (0.0 to 1.0)doubleget normalizedPressure;
}
Note that all the parameters are originated in Flutter's PointerEvent. See documentation of PointerEvent for detailed information.
Key features:
tilt and orientation enable calligraphy-style effects
normalizedPressure automatically adjusts for device-specific pressure ranges
Works seamlessly with all input devices (stylus, touch, mouse)
Path Builder Modes
Path building algorithm is also customizable. You can choose pre-defined modes below or provide your own Path Function(Stroke).
PathBuilderMode.catmullRom.converter // Smooth curves (default)PathBuilderMode.none.converter // No smoothing (straight lines)PathBuilderMode.pressureSensitive.converter // Variable-width based on pressure
Pressure-Sensitive Drawing
Create variable-width strokes that respond to stylus pressure using PathBuilderMode.pressureSensitive:
The strokePainter callback allows you to fully customize how strokes are rendered. You can create advanced visual effects like gradients, glows, shadows, and shader effects by returning multiple Paint objects.
The package provides utility functions for creating Paint objects:
paintWithDefault - Creates a paint with default properties
paintWithOverride - Creates a paint with overridden properties
eraseWithDefault - Creates a paint with BlendMode.clear for pixel-level erasing
Using with InteractiveViewer
The shouldAbsorbScale callback allows you to control which pointer events are handled by the Draw widget versus parent widgets like InteractiveViewer. This enables powerful combinations like:
Touch for pan/zoom, stylus for drawing
Device-specific gesture handling
Conditional pointer event absorption
InteractiveViewer(
child: Draw(
strokes: _strokes,
shouldAbsorbScale: (event) {
// Absorb stylus events for drawing, let touch events pass through for pan/zoomreturn event.kind == PointerDeviceKind.stylus ||
event.kind == PointerDeviceKind.invertedStylus;
},
onStrokeDrawn: (stroke) => setState(() => _strokes.add(stroke)),
onStrokeStarted: (newStroke, currentStroke) {
if (currentStroke != null) return currentStroke;
// Only draw with stylus (touch is for pan/zoom)return newStroke.deviceKind == PointerDeviceKind.stylus ? newStroke : null;
},
),
)
See the example app for a complete implementation of touch-for-pan/stylus-for-draw functionality.
Working with AI Assistants
This package is designed to work well with AI coding assistants. If you want accurate response from AI agents, refer AI_GUIDE.md before asking.