fetchGeocode method

Future<List<MFGeocodeResult>> fetchGeocode({
  1. MFLocationComponent? location,
  2. String? address,
  3. MFViewboxComponent? viewbox,
})

Geocode

Implementation

Future<List<MFGeocodeResult>> fetchGeocode(
    {MFLocationComponent? location,
    String? address,
    MFViewboxComponent? viewbox}) async {
  final Map<String, Object> data = <String, Object>{};

  if (location != null) {
    data['location'] = location.toJson();
  }
  if (address != null) {
    data['address'] = address;
  }
  if (viewbox != null) {
    data['viewbox'] = viewbox.toJson();
  }

  final response =
      await _ServicesChannel.invokeService('geocode#geocode', data);
  validateResponse(response);

  return toListGeocode(response!['result']);
}