DarshanGowda0 / GeoFlutterFire

:fire:GeoFlutterFire:fire: is an open-source library that allows you to store and query firestore documents based on their geographic location.
https://youtu.be/MYHVyl-juUk
MIT License
305 stars 261 forks source link

Weird behavior with streambuilder #13

Closed momoDragon closed 5 years ago

momoDragon commented 5 years ago

I have a streambuilder that uses this as a stream: stream: geo .collection(collectionRef: collectionReference) .within( center: geoCenter.point( latitude: 5.437534332275391, longitude: 100.30948638916016), radius: 1000, field: field, strictMode: true)

Issue: When i do that the streambuilder does not get the data. only when i press hot reload is get the data.

What works: using this: geo .collection(collectionRef: collectionReference) .within( center: geoCenter.point( latitude: 5.437534332275391, longitude: 100.30948638916016), radius: 1000, field: field, strictMode: true) and attaching a listener to it there is no issue.

momoDragon commented 5 years ago

The stream builder builds then disappears. I can see the content flash for a split second.

algirdasmac commented 5 years ago

I have the same problem, what i see that Stream is emitting too much events (9 in total). On event no.1 I receive empty List<DocumentSnapshot>, then on Event no.2 I receive data that I need, and then on events no. 3 to no. 9 I again receive empty List<DocumentSnapshot>. This is why list is empty.

momoDragon commented 5 years ago

Yup. I have been receiving empty data too hence the streambuilder flashing. I had to force call setstate after 3 sec of the initial build to get the intended data

DarshanGowda0 commented 5 years ago

@momoDragon this issue should now be resolved by #14. Please verify the same 😄

momoDragon commented 5 years ago

Thanks Darshan. New update solved the bug. Keep it up :)

momoDragon commented 5 years ago

Darshan, streambuilder data is not updating when i change data on cloud firestore. I have to press hot reload to get the new data.

japborst commented 5 years ago

@DarshanGowda0 fixed it for me on 2.0.3

momoDragon commented 5 years ago

@japborst can u try getting data with streambuilder and then update the data on the database and see if the data has updated or not. Because in my case the streambuilder rebuilds but it still get back the old data

momoDragon commented 5 years ago

@DarshanGowda0
Also when i update the data on cloud, the number of docs i get back increases.

  1. I run the app
  2. I update the data on the db
  3. i have print(snapshot.data.length) and i am getting back the length as 2 instead of 1.
  4. edits the data
  5. print(snapshot.data.length); gives me 3 instead of 1. so every time when i edit a doc the length increases by 1.

while all this is happening, none of the document snapshot have the latest data. Hot reload will update the data and remove the extra documents.

DarshanGowda0 commented 5 years ago

@momoDragon streamBuilder is reflecting the changes as expected. But, I'm able to reproduce the duplication of data on my side too. I'm working on this rn.

momoDragon commented 5 years ago

@DarshanGowda0 any update? Because i need the plugin the work

DarshanGowda0 commented 5 years ago

@momoDragon sorry for the delay! #19 should fix the breaking changes 😄

momoDragon commented 5 years ago

@DarshanGowda0 Issue is Still happening. I am running version 2.0.3+2;

I/flutter ( 4404): eE8BfMJm3OfNLQHq7cTYrv651YJ3 I/flutter ( 4404): eE8BfMJm3OfNLQHq7cTYrv651YJ3 I/flutter ( 4404): bAqvAifIRXfHUw7M3yDO6M73ZwY2 I/flutter ( 4404): bAqvAifIRXfHUw7M3yDO6M73ZwY2 I/flutter ( 4404): oCNXsjiFbXbcHkX4j1ox7deyPma2 I/flutter ( 4404): oCNXsjiFbXbcHkX4j1ox7deyPma2 I/flutter ( 4404): a2SDIgb5DAbUteITPhckQpvtV2K3 I/flutter ( 4404): a2SDIgb5DAbUteITPhckQpvtV2K3 I/flutter ( 4404): GpF2dVMLtEUsDp8sX3pJJmio1OK2 I/flutter ( 4404): GpF2dVMLtEUsDp8sX3pJJmio1OK2 I/flutter ( 4404): kcmQnsJCNfaHWy0oeWmxGCfXDI23

This is the data that is being printed. as u can see there are duplicate ids. this happends when i edit a doc.

momoDragon commented 5 years ago

Ok after cleaning the project and running fresh. Its all good now. Thanks. Safe to close the issue now. Thanks alot again. Very Very much appreciated 🥇

rdev-software commented 5 years ago

I got 2 events for one entry as well. Latest version

justChris commented 4 years ago

There still seems to be a problem. When I use StreamBuilder with the following stream:

geoflutterfire .collection(collectionRef: Firestore.instance.collection(collectionPath)) .within( center: center, radius: radius, field: 'position', strictMode: true, );

There are 9 snapshot listeners spawning. You can see that in the monitoring section of console.cloud.google.com. It is always 9! Why?

Thanks.

Jaykocha commented 3 years ago

@JustChris I have the same problem, can you share what was the cause? For me as well it was always exactly 9 snapshot listeners spawning!