SfSignaturePad constructor
const
SfSignaturePad({
- Key? key,
- double minimumStrokeWidth = _kMinimumStrokeWidth,
- double maximumStrokeWidth = _kMaximumStrokeWidth,
- Color? backgroundColor,
- Color? strokeColor,
- SignatureOnDrawStartCallback? onDrawStart,
- SignatureDrawCallback? onDraw,
- VoidCallback? onDrawEnd,
Constructor that creates a new instance of SfSignaturePad.
The below snippet shows how to use a SfSignaturePad.
- Create a global key.
final GlobalKey<SfSignaturePadState> _signaturePadKey = GlobalKey();
- Create a SfSignaturePad and set the properties and global key.
SfSignaturePad(
minimumStrokeWidth: 3.0,
maximumStrokeWidth: 6.0,
backgroundColor: Colors.white,
strokeColor: Colors.green,
key: _signaturePadKey,
);
- Call SfSignaturePadState.clear using state object to clear all the drawn strokes in the SfSignaturePad.
_signaturePadKey.currentState.clear();
- Call SfSignaturePadState.toImage using state object to convert the signature to an image representation.
ui.Image image = await _signaturePadKey.currentState.toImage();
- Handle the start of signature gestures in SfSignaturePad from
onDrawStart
.
SfSignaturePad(
onDrawStart: () {
return false;
});
- Handle the ondraw of signature gestures in SfSignaturePad from
onDraw
.
SfSignaturePad(
onDraw: (offset, time) {
Offset offsetValue = offset;
DateTime dateTime = time;
});
- Handle the end of signature gestures in SfSignaturePad from
onDrawEnd
.
SfSignaturePad(
onDrawEnd: ()=> {
print("Signature has been completed in Signature Pad");
});
Implementation
const SfSignaturePad(
{Key? key,
this.minimumStrokeWidth = _kMinimumStrokeWidth,
this.maximumStrokeWidth = _kMaximumStrokeWidth,
this.backgroundColor,
this.strokeColor,
this.onDrawStart,
this.onDraw,
this.onDrawEnd})
: super(key: key);