Feature.fromJson constructor

Feature.fromJson(
  1. Map<String, dynamic> json
)

Creates an object from JSON data.

Implementation

factory Feature.fromJson(Map<String, dynamic> json) {
  final id = json['id'];
  final geometry = json['geometry'];
  final properties = json['properties'];

  final props =
      properties != null ? Map<String, Object>.from(properties) : null;

  Geometry? geo;

  if (geometry != null) {
    final g = Map<String, dynamic>.from(geometry);
    geo = Geometry.fromJson(g);
  }

  return Feature(
    id: id,
    geometry: geo,
    properties: props,
  );
}