toSvg method
Converts data to svg
String.
type
- data structure.
Implementation
String? toSvg({
SignatureDrawType type: SignatureDrawType.shape,
bool wrapSignature: false,
Size? size,
double border: 0.0,
Color? color,
double? strokeWidth,
double? maxStrokeWidth,
}) {
assert(wrapSignature || size != null);
if (!isFilled) {
return null;
}
params ??= SignaturePaintParams(
color: Colors.black,
strokeWidth: 1.0,
maxStrokeWidth: 10.0,
);
color ??= params!.color;
strokeWidth ??= params!.strokeWidth;
maxStrokeWidth ??= params!.maxStrokeWidth;
final bounds = PathUtil.boundsOf(_offsets);
final rect = _getSvgRect(wrapSignature, size, bounds);
if (type == SignatureDrawType.line || type == SignatureDrawType.shape) {
final data = PathUtil.fillData(
_cubicLines,
rect,
bound: bounds,
border: maxStrokeWidth + border,
);
return type == SignatureDrawType.line
? _exportPathSvg(data, rect.size, color, strokeWidth)
: _exportShapeSvg(
data,
rect.size,
color,
strokeWidth,
maxStrokeWidth,
);
} else {
final data = PathUtil.fill(
_arcs,
rect,
bound: bounds,
border: maxStrokeWidth + border,
);
return _exportArcSvg(data, rect.size, color, strokeWidth, maxStrokeWidth);
}
}