When it comes to geo searches in Flutter, geoFlutterFire is the go to solution https://pub.dev/packages/geoflutterfire One issue with it is that it does not have a single query functionality only Stream (https://github.com/DarshanGowda0/GeoFlutterFire/issues/27).
In a regular Streambuilder, could I increase the radius once I have the first snapshot, and its empty by setting a radius variable, and disposing the stream, and then setting state?
Would I need to dispose the stream before calling setState? It is said here that if we remove a widget from the tree the stream cancels Flutter: Streambuilder - Closing of streams Would a setState remove the current widget and reload as a new Streambuilder?
Sg like
Widget build(BuildContext context) {
int radius = 1;
return StreamBuilder<List<DocumentSnapshot>>(
stream: geoFlutterFireInstance.collection(collectionRef: globals.usersCollection)
.within(
center: GeoFirePoint(
geolocatorPosition.latitude,
geolocatorPosition.longitude,
),
radius: radius,
field: 'position',
strictMode: true,
);,
builder: (
BuildContext context,
AsyncSnapshot<List<DocumentSnapshot>> asyncSnapshot,
) {
if (asyncSnapshot.hasError) {
return Center(child: Text(asyncSnapshot.error.toString()));
} else {
switch (asyncSnapshot.connectionState) {
case ConnectionState.none:
case ConnectionState.waiting:
return Container(...),
case ConnectionState.active:
if (asyncSnapshot.data.length == 0 && radius <= 10)
{radius++; setState(() {
});}
PS I found a recommendation to use StreamController at Flutter How to refresh StreamBuilder? will check that out