beerstorm-net / GeoFlutterFire2

🔥GeoFlutterFire2🔥 is an open-source library that allows you to store and query firestore documents based on their geographic location.
https://pub.dev/packages/geoflutterfire2
MIT License
14 stars 34 forks source link

Query data once #6

Open aliakkawi opened 2 years ago

aliakkawi commented 2 years ago

In my case i need get user Documents on a specific radius and i need that only 'Once', which means i need a way to do that without using Stream. The use of stream causes 'Background concurrent copying GC freed' that leads to memory leaks and freezes the app, I tried to use Stream Subscription and cancel it as soon i receive data for the first time, but i guess the Stream is not getting stopped. I need a way to do it like this QuerySnapshot querySnapshot = await query.get();

Thanks for your suggestions

FloLecoeuche commented 1 year ago

This is what you're looking for ? https://github.com/DarshanGowda0/GeoFlutterFire/pull/193

kamami commented 1 year ago

Is this eventually available?

pawlowskim commented 1 year ago

I have described root cause of not disposing the underlaying stream in here: https://github.com/beerstorm-net/GeoFlutterFire2/pull/26

when this is merged (or you can play around with the fork), you can use new method and then just call first on the stream, which will close the the stream right away, as it says in the the doc: https://api.flutter.dev/flutter/dart-async/Stream/first.html

giorgio79 commented 1 year ago

Duplicate of https://github.com/DarshanGowda0/GeoFlutterFire/issues/27 just cancel the stream

pawlowskim commented 1 year ago

It won't cancel the stream @giorgio79, it will only cancel the subscription for broadcast stream which was outcome of merged 9 streams under the hood. Original stream will still be active, but you don't have access to it without any code changes.