सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
Draw_Your_Image एक Flutter पैकेज है जो उपयोगकर्ताओं को अपनी उंगलियों या स्टाइलस के साथ कस्टम UI पर सीधे ड्रॉ करने की अनुमति देता है। यह ऐप में स्केचिंग, पेंटिंग या साइन करने के लिए एक सरल, इंटरैक्टिव कैनवास प्रदान करता है। रचनात्मक उपकरण, नोट-टेकिंग ऐप्स या डिजिटल साइनेचर कैप्चर के लिए आदर्श, यह मोबाइल, वेब और डेस्कटॉप सहित कई प्लेटफॉर्म का समर्थन करता है। पैकेज Flutter के विजेट सिस्टम के साथ आसानी से एकीकृत है और कस्टमाइज़ेबल ब्रश सेटिंग्स प्रदान करता है। यह ओपन-सोर्स है और एक समर्पित डेवलपर द्वारा बनाए रखा जाता है।
उपयोग
डिजिटल स्केचिंग
हस्ताक्षर अधिग्रहण
इंटरैक्टिव व्हाइटबोर्ड
शैक्षिक ड्राइंग ऐप्स
रचनात्मक डिज़ाइन टूल्स
मुख्य विशेषताएँ
टच-आधारित ड्राइंग
कस्टमाइज़ किए गए ब्रश आकार और रंग
क्रॉस-प्लेटफ़ॉर्म समर्थन
Flutter के साथ सरल एकीकरण
ओपन-सोर्स कोडबेस
इनके लिए उपयुक्त
रचनात्मक उपकरण बनाने वाले ऐप विकासकर्ता
इंटरैक्टिव लर्निंग ऐप बनाने वाले शिक्षक
उपयोगकर्ता हस्ताक्षर की आवश्यकता वाले ऐप्स
ग्राफिक विशेषताओं की आवश्यकता वाले डिज़ाइनर
इंटरैक्टिव इंटरफेस का प्रोटोटाइपिंग
विचार योग्य बातें
कम क्षमता वाले उपकरणों पर प्रदर्शन में भिन्नता हो सकती है
सीमित उन्नत संपादन उपकरण
कोई निर्मित निर्यात कार्यक्षमता नहीं है
सहेजने/लोड करने के लॉजिक को हाथ से संभालने की आवश्यकता है
ब्रश कस्टमाइजेशन विकल्प मूलभूत हैं
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
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.