toPathList method

List<Path> toPathList()

Creates an unmodifiable ui.Path collection which represents the 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 toPathList in SfSignaturePadState.

  • Create a global key.
final GlobalKey<SfSignaturePadState> _signaturePadKey = GlobalKey();
SfSignaturePad(
  key: _signaturePadKey,
 );
  • Call toPathList using the state object to expose the path collection.
List<Path> paths = signatureGlobalKey.currentState!.toPathList();

Implementation

List<Path> toPathList() {
  final RenderObject? signatureRenderBox = context.findRenderObject();
  List<Path> paths = <Path>[];

  if (signatureRenderBox is RenderSignaturePad) {
    paths = List<Path>.unmodifiable(signatureRenderBox._pathCollection);
  }

  return paths;
}