简体   繁体   中英

Flutter Firestore endBeforeDocument doesn't work

await FirebaseFirestore.instance
      .collection('NewCardsList')
      .orderBy('timestamp')
      .endBeforeDocument(oldestDocID)
      .limitToLast(_theNumberOfFetchingOldCard)
      .get()
      .then(...);

I made this code 3-4month ago and it worked well.

However it suddenly doesn't work...

I'm checking the code with breakpoint with every single line and there is no reaction after ".then() line". (Does not go to the next line)

And I found that it works well if I remove ".endBeforeDocument() method".

      DocumentSnapshot oldestDocID = await FirebaseFirestore.instance
      .collection('NewCardsList')
      .doc(cardManagementProvider.newCardsIDList.last)
      .get();
  print('############# ${oldestDocID.id}');

This code is for getting DocumentSnapshot in ".endBeforeDocument() method".

I could see correct result with print() to see DocumentSnapshot.

Please give me some comment about this problem.

I solved it after changing logic with startAfterDocument().

But I still cannot understand why it does not work with endBeforeDocument()

await FirebaseFirestore.instance
      .collection('NewCardsList')
      .orderBy('timestamp', descending: true)
      .startAfterDocument(oldestDocID)
      .limit(_theNumberOfFetchingOldCard)
      .get()
      .then(...);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM