I've run into a really weird error, and I can't wrap my head around it.
I do a query like this:
var currentSnapshot = await Firestore.instance
.collection('station1')
.orderBy("servertime", descending: true)
.limit(1)
.snapshots()
.first;
To get the most recent document in some collection based on the server-timestamp that I have on each document. For some reason, this results in retrieving the newest documents only when debugging line by line. This could indicate that it has something to do with timing, as I'm introducing a lot more time when stepping through things.
The code is called every X seconds through the use of this:
Timer.periodic(Duration(seconds: 120), (Timer t) => updateMeasurements());
When I run without stepping through it with the debugger, it seems to only retrieve the correct value the first time, and when there are new documents added in the collection, it does not retrieve these.
Am I doing any obvious mistakes? Any ideas on what to try? All help appreciated!