industrial_drawing_flutter 1.0.3
industrial_drawing_flutter: ^1.0.3 copied to clipboard
A high-performance, production-ready vector drawing engine for Flutter. Designed for industrial applications and engineering tools.
Industrial Drawing Flutter 🎨 #
A high-performance, production-ready vector drawing engine for Flutter. Designed for industrial applications, engineering tools, and creative whiteboards. Built with a modular architecture that separates the rendering engine from the UI.
✨ Features #
- 🛠 Precision Tools: Line, Rectangle, Circle, Triangle, and Freehand drawing.
- 📏 Measurement Mode: Built-in distance and dimension calculation.
- 🔄 State Management: Robust Undo/Redo stack with historical state snapshots.
- 📱 Hardware Accelerated: Optimized
CustomPainterrendering withRepaintBoundarysupport. - 💾 Persistence: Native support for exporting to PNG and serializing to JSON for cloud storage.
- 🔍 Infinite Canvas: Support for smooth Pan and Zoom (Scale) interactions.
- 📐 Shape Snapping: Intelligent alignment and snapping for technical accuracy.
🏗 Architecture #
This package follows a Senior Package Maintainer architecture to ensure 130+ pub points and maximum reusability:
lib/
├── drawing_engine.dart # Public API (Barrel file)
└── src/
├── controllers/ # DrawingController (Business Logic)
├── models/ # Immutable Data Models (DrawnShape)
├── painters/ # Pure CustomPainter Logic
└── widgets/ # DrawingCanvas (Presentation Layer)
🚀 Getting Started #
1. Installation #
Add this to your pubspec.yaml:
dependencies:
industrial_drawing_flutter:
path: ./ # Or latest version from pub.dev
2. Basic Usage #
import 'package:industrial_drawing_flutter/drawing_engine.dart';
// 1. Initialize the Controller
final controller = DrawingController();
// 2. Add the Canvas to your UI
DrawingCanvas(
controller: controller,
showGrid: true,
)
// 3. Control drawing programmatically
controller.currentTool = DrawingTool.draw;
controller.currentShapeType = ShapeType.rectangle;
controller.undo();
🔧 Controller API #
The DrawingController is the brain of your application:
| Method / Property | Description |
|---|---|
shapes |
Returns an unmodifiable list of all drawn elements. |
addShape(DrawnShape) |
Manually add a shape to the canvas. |
undo() / redo() |
Navigate through the action history. |
saveToFile(path) |
Serialize the current canvas state into a JSON file. |
currentTool |
Toggle between draw, select, pan, and measure. |
🛠 Design Decisions (Senior Reviewer Focus) #
- Headless Logic: All drawing calculations are performed in the
DrawingController, allowing you to write unit tests without needing a UI. - Lazy Repainting: The
DrawingPainteronly repaints when necessary to preserve battery and performance on mobile devices. - Immutable Models:
DrawnShapeobjects are immutable clones during undo/redo to prevent side effects.
📄 License #
This project is licensed under the MIT License - see the LICENSE file for details.
🤝 Contributing #
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request