fromJson static method

PathSource fromJson(
  1. Map<String, Object?> json
)

Implementation

static PathSource fromJson(Map<String, Object?> json) {
  final k = json['kind'];
  switch (k) {
    case 'commands':
      return CommandPathSource.fromJson(json);
    case 'polyline':
      return PolylineSource.fromJson(json);
    case 'rect':
      return RectSource.fromJson(json);
    case 'roundRect':
      return RoundRectSource.fromJson(json);
    case 'pill':
      return PillSource.fromJson(json);
    case 'underline':
      return UnderlineSource.fromJson(json);
    case 'ellipse':
      return EllipseSource.fromJson(json);
    case 'svg':
      throw const FormatException(
        'SVG path strings are unsupported. Normalize to a commands source '
        'before loading.',
      );
    case 'circle':
      return CircleSource.fromJson(json);
    case 'regularPolygon':
      return RegularPolygonSource.fromJson(json);
    case 'star':
      return StarSource.fromJson(json);
    default:
      throw FormatException('Unknown PathSource kind: $k');
  }
}