serializable_sketch 0.1.0
serializable_sketch: ^0.1.0 copied to clipboard
A Flutter library for creating and serializing sketches into smooth Bezier-based JSON and SVG formats.
serializable_sketch #
A Flutter library that allows users to create sketches, smooths them using cubic Bezier curves, and serializes the result into JSON or SVG formats.
Features #
- Bezier Smoothing: Automatically converts raw touch points into smooth cubic Bezier curves.
- Serialization:
- Save and load sketches using JSON.
- Export sketches to high-quality SVG strings.
- File Saving: Built-in support (in example) for saving files to specific locations using native file pickers.
- Real-time Preview: Shows a faint preview of the path while drawing.
- Easy Integration: Simple
SketchCanvaswidget for immediate use.
Installation #
Add this to your pubspec.yaml:
dependencies:
serializable_sketch: ^0.1.0
Usage #
Basic Drawing Canvas #
import 'package:serializable_sketch/serializable_sketch.dart';
// ... inside your widget ...
SketchCanvas(
paths: _paths,
onPathsChanged: (newPaths) {
setState(() {
_paths = newPaths;
});
},
strokeColor: Colors.blue,
strokeWidth: 4.0,
smooth: true,
)
Serialization #
// To JSON
String json = SketchSerializer.toJson(_paths);
// From JSON
List<SketchPath> loadedPaths = SketchSerializer.fromJson(json);
// To SVG
String svg = SketchSerializer.toSvg(_paths, width: 800, height: 600);
License #
This project is licensed under the MIT License - see the LICENSE file for details.