MapPointValue.fromJson constructor

MapPointValue.fromJson(
  1. Object? value,
  2. String path
)

Implementation

factory MapPointValue.fromJson(Object? value, String path) {
  if (value is! Map) {
    throw SchemaFormatException(path, 'expected a map point object');
  }

  final lat = _pointNumber(value['lat']);
  final lng = _pointNumber(value['lng']);
  if (lat == null || lng == null) {
    throw SchemaFormatException(
      path,
      'map point must contain numeric lat and lng',
    );
  }

  return MapPointValue(lat: lat, lng: lng);
}