Point.fromJson constructor

Point.fromJson(
  1. Map<String, dynamic> m
)

Factory constructor which reads x-y-z-values from a map

Implementation

factory Point.fromJson(Map<String, dynamic> m) {
  int length = m.length;
  assert(length == 2 || length == 3, 'Point must have 2 or 3 dimensions');

  if (length == 2) {
    return Point._(m['x'], m['y'], 0);
  }

  return Point._(m['x'], m['y'], m['z']);
}