簽名套件是一個 Flutter 插件,提供高效率的畫布來捕捉數位簽名。支援自訂樣式、邊界限制與初始狀態設定,非常適合用於表單與驗證流程。此套件設計為跨平台使用,可在 Android、iOS、Web、macOS、Windows 與 Linux 上順暢運作。該插件確保繪製過程平滑且延遲極低,並透過可設定選項提供外觀與行為上的彈性。
適用情境
數位簽章收集
帶簽名驗證的表單提交
驗證工作流程
電子簽名整合
用戶身份驗證
主要特色
可自訂的描邊樣式和顏色
簽名區域的邊界限制
初始狀態支援(例如,預填的簽名)
高效能渲染
跨平台相容性
可設定的畫布大小與內邊距
適合對象
需要電子簽名功能的應用開發者
需要使用者身分驗證的表單
具有繪圖需求的行動與Web應用
具備合規性要求的企业應用
針對多個平台的應用程式
使用建議
需要正確處理畫布大小與縮放
可能需要額外的驗證來確保簽名的真實性
效能取決於裝置功能
僅限基本繪圖;不適用於複雜繪畫
除了影像資料之外,沒有內建的匯出格式
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
signature
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.
Why
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
Migration to 5.0.0+
This version no longer wraps Signature in Expanded widget if you are using
it without specifying dimensions
This removes error Incorrect use of ParentDataWidget, see
this issue for more
information.
If you are passing dimensions to widget, you do not have to change anything.
If you are using widget without dimensions inside Row, Column or Flex
widgets, you have to wrap Signature inside Expanded yourself.
If you are using widget without dimensions, but not inside mentioned widgets
you do not have change anything and error should dissapear from your logs :)
Take a look at our example project as well: Signature Demo
// IMPORT PACKAGEimport'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 widgetfinalSignatureController _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 CONTROLLERfinalSignatureController _controller = SignatureController(points: exportedPoints);
//DONT FORGET TO DISPOSE IT IN THE `dispose()` METHOD OF STATEFUL WIDGETS@overridevoiddispose() {
_controller.dispose();
super.dispose();
}