SfSignaturePad constructor Null safety

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();
SfSignaturePad(
  onDrawStart: () {
    return false;
  });
SfSignaturePad(
  onDraw: (offset, time) {
    Offset offsetValue = offset;
    DateTime dateTime = time;
  });
 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);