nearby method

Future<Iterable<BusinessInfo>> nearby({
  1. String? name,
  2. required double latitude,
  3. required double longitude,
  4. int radius = 500,
})

Locate businesses around latitude and longitude coords

Implementation

Future<Iterable<BusinessInfo>> nearby(
    {String? name,
    required double latitude,
    required double longitude,
    int radius = 500}) async {
  final locale = PlatformDispatcher.instance.locales.first;
  final queryParameters = {
    'location': '$latitude,$longitude',
    'radius': radius,
    'language': locale.languageCode
  };
  if (name != null) queryParameters['name'] = name;
  final data = await _apiRequest('place/nearbysearch/json',
      queryParameters: queryParameters);
  return (data['results'] as List).map((e) => BusinessInfo.fromJson(e));
}