getLocationSuggestions static method

Future<List<String>> getLocationSuggestions(
  1. Position position, {
  2. bool includeCurrentPosition = true,
})

Implementation

static Future<List<String>> getLocationSuggestions(Position position, {bool includeCurrentPosition = true}) async {
  List<String> suggestions = await GeoLocatorController().getNearbySimpleAddresses(position);

  if(includeCurrentPosition) {
    Position? currentPosition = await GeoLocatorController().getCurrentPosition();

    if(currentPosition != null) {
      String currentAddress = await GeoLocatorController().getAddressSimple(currentPosition);
      if(!suggestions.contains(currentAddress)) {
        suggestions.add(currentAddress);
      }
    }
  }

  return suggestions;
}