0 purchases
digital signature flutter
his library is used to capture a signature through drawing gestures.
You can use your finger, pen, or mouse on a tablet, touchscreen, etc.,
to draw your own signature in this SignaturePad widget.
The widget also allows you to save a signature as an image.
Usage #
Create a new flutter Project
Open a Flutter project, go to pubspec.yaml file and add the following dependency
digital_signature_flutter: ^0.0.3
copied to clipboard
Flutter pub get
Inside lib create a new dart file for digital signature
Create a digitalSignature class
Inside this class, we need to define the controller
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: size2, penColor: Colors.white);
copied to clipboard
PenStrokeWidth – initialize the pen width
PenColor – initialize the pencolor for digital signature
To convert signature to png bytes by using unit8list
late final Uint8List? signature;
copied to clipboard
Define Digital signature pad
Center(
child: SizedBox(
height: size300,
width: size350,
child: Signature(
height: size300,
width: size350,
controller: controller,
backgroundColor: Colors.grey,
),
),
),
copied to clipboard
Export digital signature into png bytes
Future<Uint8List?> exportSignature() async {
final exportController = SignatureController(
penStrokeWidth: size2,
exportBackgroundColor: Colors.white,
penColor: Colors.black,
points: controller.points,
);
final signature = exportController.toPngBytes();
//clean up the memory
exportController.dispose();
return signature;
}
copied to clipboard
View digital signature In Image view
signature = await exportSignature();
signature!=null?Center(
child: Image.memory(signature!)
):Container()
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.