GeocodingApiResponse.fromJson constructor

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

Implementation

GeocodingApiResponse.fromJson(Map<String, dynamic> json) {
  final _message = json['message'] as String?;

  if (_message != null) {
    error = GeocoderError(message: _message);
  }

  type = json['type'] as String?;
  attribution = json['attribution'] as String?;

  if (json.containsKey('query') && json['query'] != null) {
    query = List<String>.from(
      (json['query'] as List<dynamic>).map((query) => query.toString()),
    );
  }

  if (json.containsKey('features') && json['features'] != null) {
    features = List<GeocoderFeature>.from(
      (json['features'] as List<dynamic>).map(
        (feature) => GeocoderFeature.fromJson(
          feature as Map<String, dynamic>,
        ),
      ),
    );
  }
}