uiPathFrom function

Path uiPathFrom(
  1. GeometryPath path
)

Converts a core GeometryPath into a dart:ui path.

Implementation

ui.Path uiPathFrom(GeometryPath path) {
  final p = ui.Path();
  for (final c in path.commands) {
    switch (c) {
      case MoveTo(:final x, :final y):
        p.moveTo(x, y);
      case LineTo(:final x, :final y):
        p.lineTo(x, y);
      case CubicTo(
          :final c1x,
          :final c1y,
          :final c2x,
          :final c2y,
          :final x,
          :final y
        ):
        p.cubicTo(c1x, c1y, c2x, c2y, x, y);
      case QuadraticTo(:final cx, :final cy, :final x, :final y):
        p.quadraticBezierTo(cx, cy, x, y);
      case ClosePath():
        p.close();
    }
  }
  return p;
}