SfSignaturePad constructor

const SfSignaturePad({
  1. Key? key,
  2. double minimumStrokeWidth = _kMinimumStrokeWidth,
  3. double maximumStrokeWidth = _kMaximumStrokeWidth,
  4. Color? backgroundColor,
  5. Color? strokeColor,
  6. SignatureOnDrawStartCallback? onDrawStart,
  7. SignatureDrawCallback? onDraw,
  8. 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();
SfSignaturePad(
  minimumStrokeWidth: 3.0,
  maximumStrokeWidth: 6.0,
  backgroundColor: Colors.white,
  strokeColor: Colors.green,
  key: _signaturePadKey,
 );
_signaturePadKey.currentState.clear();
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);