How to filter algolia search hits based on geolocation in flutter

Viewed 38

I implemented the algolia search in my flutter project using this package https://pub.dev/packages/algolia/example the problem is I can't find documentation on how to filter searches based on geolocation. let's say my search results should only be within a 50km radius from my lat/long. how can I implement this? here is the setup of my geolocenter image description here

and below is my function where i need to implement the filter. any help would be greatly appreciated.

Future<List<T>> getItems<T>(
      {required String index,
      required String locality,
      required T Function(Map<String, dynamic> data, String documentId) builder,
      required String searchValue}) async {
    final result =
        algolia.instance.index(index).query(searchValue).setHitsPerPage(10);

    final filtered = result.filters('//How to write a filter here?'); 
    
    final snap = await filtered.getObjects();
    return snap.hits
        .map((snapshot) => builder(snapshot.data, snapshot.objectID))
        .where((value) => value != null)
        .toList();
  }

0 Answers
Related