Aus öffentlichen Paketdaten erstellte Orientierung.
Draw_Your_Image ist ein Flutter-Paket, das Benutzern ermöglicht, direkt auf einer benutzerdefinierten Benutzeroberfläche mit Fingern oder Stift zu zeichnen. Es bietet eine einfache, interaktive Leinwand zum Skizzieren, Malen oder Unterschreiben innerhalb von Apps. Ideal für kreative Werkzeuge, Notiz-Apps oder die Erfassung digitaler Unterschriften, unterstützt es mehrere Plattformen wie Mobilgeräte, Web und Desktop. Das Paket integriert sich nahtlos in das Widget-System von Flutter und bietet anpassbare Pinsel-Einstellungen. Es ist Open Source und wird von einem engagierten Entwickler gepflegt.
Anwendungsfälle
Digitales Skizzieren
Unterschriftserfassung
Interaktive Whiteboards
Lernprogramme zum Zeichnen
Kreative Gestaltungstools
Hauptmerkmale
Touch-basiertes Zeichnen
Anpassbare Pinselgröße und -farbe
Plattformübergreifende Unterstützung
Einfache Integration mit Flutter
Open-Source-Codebase
Geeignet für
App-Entwickler, die kreative Tools erstellen
Bildungsexperten, die interaktive Lernanwendungen erstellen
Apps, die Benutzerunterschriften erfordern
Designer, die Zeichenfunktionen benötigen
Prototyping interaktiver Schnittstellen
Hinweise
Die Leistung kann sich auf Geräten mit geringer Leistung unterscheiden
Begrenzte fortgeschrittene Bearbeitungswerkzeuge
Keine integrierte Exportfunktion
Erfordert manuelle Handhabung der Speichern/Laden-Logik
Die Anpassungsoptionen für Pinsel sind grundlegend
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
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.