clear method
void
clear()
Clears all the signature strokes in the SfSignaturePad.
Since this method is defined in the state object of SfSignaturePad, you have to use a global key assigned to the SfSignaturePad to call this method. This snippet shows how to use clear in SfSignaturePadState.
- Create a global key.
final GlobalKey<SfSignaturePadState> _signaturePadKey = GlobalKey();
- Create a SfSignaturePad instance and assign the global key to it.
SfSignaturePad(
key: _signaturePadKey,
);
- Call clear using the state object to clear the all signature strokes.
_signaturePadKey.currentState!.clear();
Implementation
void clear() {
final RenderObject? signatureRenderBox = context.findRenderObject();
if (signatureRenderBox is RenderSignaturePad) {
signatureRenderBox.clear();
}
}