parseSvgPathData function

Path parseSvgPathData(
  1. String data, {
  2. PathFillType fillType = ui.PathFillType.nonZero,
})

Parses the SVG path data grammar (the d attribute of <path>) into a ui.Path.

The full command set is supported — M m Z z L l H h V v C c S s Q q T t A a — including implicit command repetition (M 0 0 10 10 continues as L), implicit sign separation (10-5), exponent notation, and compact arc flags (a5 5 0 0150 5).

Elliptical arcs map onto ui.Path.arcToPoint, which implements the same endpoint parameterization; a zero radius degenerates to a line, as the SVG specification requires.

Throws a FormatException on malformed input, with the offending offset.

Implementation

ui.Path parseSvgPathData(
  String data, {
  ui.PathFillType fillType = ui.PathFillType.nonZero,
}) {
  final ui.Path path = ui.Path()..fillType = fillType;
  _SvgPathDataParser(data, path).run();
  return path;
}