addresses method

Future<List<Address>> addresses(
  1. String name, {
  2. String? countryCode,
})

Find addresses by partial name

Implementation

Future<List<Address>> addresses(String name, {String? countryCode}) async {
  final queryParameters = {'input': name};
  if (countryCode != null) {
    queryParameters['components'] = 'country:$countryCode';
  }
  final data = await _apiRequest('place/autocomplete/json',
      queryParameters: queryParameters);
  return (data['predictions'] as List)
      .map((e) => Address.fromJson(e))
      .toList();
}