search method

Future<GoogleGeocodingResponse> search(
  1. String address, {
  2. String? bounds,
  3. String? language,
  4. String? region,
  5. String? components,
})

Implementation

Future<GoogleGeocodingResponse> search(
  String address, {
  String? bounds,
  String? language,
  String? region,

  /// More info at
  /// https://developers.google.com/maps/documentation/geocoding/overview#component-filtering
  String? components,
}) async {
  final Map<String, dynamic> query = <String, dynamic>{
    'address': address.replaceAll(' ', '+'),
    if (bounds != null) 'bounds': bounds,
    if (language != null) 'language': language,
    if (region != null) 'region': region,
    if (components != null) 'components': components,
  };

  final Response<Map<String, dynamic>> response =
      await _dio.get<Map<String, dynamic>>(
    _baseUrl,
    queryParameters: query,
  );
  return _mapOrThrow(response.data!);
}