A Flutter plugin providing performance optimized signature canvas with ability to set custom style, boundaries and initial state. This is native flutter implementation, so it supports all platforms.
In time of creation of this plugin, there was no available solution that had:
- required performance on wide range of devices
- ability to set canvas boundaries
- ability to initialize using previously saved state
To use this plugin, add
signature as a dependency in your
// IMPORT PACKAGE import 'package:signature/signature.dart'; // Initialise a controller. It will contains signature points, stroke width and pen color. // It will allow you to interact with the widget final SignatureController _controller = SignatureController(penStrokeWidth: 5, penColor: Colors.red); // INITIALIZE. RESULT IS A WIDGET, SO IT CAN BE DIRECTLY USED IN BUILD METHOD var _signatureCanvas = Signature( controller: _controller, width: 300, height: 300, backgroundColor: Colors.lightBlueAccent, ); // CLEAR CANVAS _controller.clear(); // EXPORT BYTES AS PNG // The exported image will be limited to the drawn area _controller.toPngBytes(); // isEmpty/isNotEmpty CAN BE USED TO CHECK IF SIGNATURE HAS BEEN PROVIDED _controller.isNotEmpty; //true if signature has been provided _controller.isEmpty; //true if signature has NOT been provided // EXPORT POINTS (2D POINTS ROUGHLY REPRESENTING WHAT IS VISIBLE ON CANVAS) var exportedPoints = _controller.points; //EXPORTED POINTS CAN BE USED TO INITIALIZE PREVIOUS CONTROLLER final SignatureController _controller = SignatureController(points: exportedPoints);
Contribution and Support #
- Contributions are welcome!
- If you want to contribute code please create a PR
- If you find a bug or want a feature, please fill an issue
- Merged awesome controller implementation from jeanmatthieud that solves many bugs in cases where widget is not available (braking change)
- Fixed problems when writing too fast
- Fixed conflict between scrolling scroll container and drawing the signature
Migration from 2.x.x:
- You have to provide SignatureController and use it to manipulate with data instead using widget itself. Api is almost same but it is now split between
- See updated example.
- Fixed null pointer in case that future was resolved after widget has been removed from tree on slower devices
- Migration from
androidxpackages that allows this library to be used with flutter projects that use
androidx. If you need to stay on
android.supportfor whatever reason, don't upgrade as it may break your build. See more.
- Fixed breaking change in Picture.toImage in latest flutter
- New properties isEmpty and isNotEmpty at Signature class for validation purposes
- fixed bug where canvas was not writable in case of specific boundary setup
- removed debug statements and cleanup
- README modifications and code reformat
- Initial release
Demonstrates how to use the signature plugin.
Getting Started #
For help getting started with Flutter, view our online documentation.
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies: signature: ^3.0.0
2. Install it
You can install packages from the command line:
$ flutter pub get
Alternatively, your editor might support
flutter pub get.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Jan 21, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.7.0
- pana: 0.13.4
- Flutter: 1.12.13+hotfix.5
lib/signature.dart. (-0.50 points)
lib/signature.dart reported 1 hint:
line 2 col 8: Unused import: 'dart:math'.
flutter format to format