Orientação gerada a partir de informações públicas. Apenas para referência.
Draw_Your_Image é um pacote Flutter que permite aos usuários desenhar diretamente em uma interface personalizada usando os dedos ou um estilete. Ele oferece uma tela interativa simples para esboçar, pintar ou assinar dentro de aplicativos. Ideal para ferramentas criativas, aplicativos de anotações ou captura de assinaturas digitais, suporta múltiplas plataformas, incluindo móvel, web e desktop. O pacote se integra perfeitamente ao sistema de widgets do Flutter e oferece configurações personalizáveis de pincel. É de código aberto e mantido por um desenvolvedor dedicado.
Casos de uso
Desenho digital
Captura de assinatura
Quadros brancos interativos
Aplicativos educacionais de desenho
Ferramentas de design criativo
Principais recursos
Desenho baseado em toque
Tamanho e cor de pincel personalizáveis
Suporte multiplataforma
Integração simples com o Flutter
repositório de código aberto
Indicado para
Desenvolvedores de aplicativos que criam ferramentas criativas
Educadores criando aplicativos interativos de aprendizagem
Aplicativos que exigem assinaturas de usuário
Designers que precisam de recursos de desenho
Prototipagem de interfaces interativas
Considerações
O desempenho pode variar em dispositivos de baixa gama
Ferramentas avançadas de edição limitadas
Nenhuma funcionalidade de exportação embutida
Requer o tratamento manual da lógica de salvar/carregar
As opções de personalização do pincel são básicas
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
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.