v6.3.0
signature
一個 Flutter 外掛,提供效能優化的簽名畫布,可設定自訂樣式、邊界與初始狀態。
657喜歡 21.1萬近 30 天下載160Pub 分數
AndroidiOSWebmacOSWindowsLinux
建立簽名畫布的 Flutter 外掛
{"sdk":"flutter"}^2.1.0{"sdk":"flutter"}以下為英文專案原文快照,最新內容請造訪 GitHub。
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:
Signature in Expanded widget if you are using
it without specifying dimensionsIncorrect use of ParentDataWidget, see
this issue for more
information.Row, Column or Flex
widgets, you have to wrap Signature inside Expanded yourself.To use this plugin, add signature as a
dependency in your pubspec.yaml file.
Take a look at our example project as well: Signature Demo
// 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,
exportBackgroundColor: Colors.blue,
);
// 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);
//DONT FORGET TO DISPOSE IT IN THE `dispose()` METHOD OF STATEFUL WIDGETS
@override
void dispose() {
_controller.dispose();
super.dispose();
}
Example image