0

I am trying to generate a list containing the 'name' parameters as Strings from this Firestore.instance.collection('videos').limit(10).snapshots(); query, but I am having trouble extracting the parameter values from the documents and returning them as a list. Would I have to use .forEach() or do I have to .map() the entries to a list? Any help would be highly appreciated!

Edit: Additionally I would like to query the documents in a certain range, but .startAt() does not seem to accept integers. Is there any way to query say the first 10 documents by using Firestore.instance.collection('videos').startAt(0).limit(10).snapshots();?

stefanmuke
  • 399
  • 6
  • 20
  • What about [FirebaseAnimatedList](https://stackoverflow.com/questions/46912713/how-to-query-in-a-flutter-firebaseanimatedlist-using-buildarguments-or-anything). And for the second question you can use orderByKey() or orderByChild() but as default it will order data according to time that you are added. You can get an idea here:https://stackoverflow.com/questions/45351742/how-to-retrieve-range-of-data-in-firebase – Blasanka Jun 06 '18 at 15:26
  • @Blasanka Thanks a lot for your comment! As for the Firebase Animated list, this seems to be only available for the Firebase Realtime Database, not Cloud Firestore. The list part itself (scroll threshold etc.) has already been figured out, I was mainly looking for a way to create a List (the Dart type, https://api.dartlang.org/stable/1.24.3/dart-core/List-class.html) out of Firestore query parameters. Do you know how to do that? Thanks again for your answer! – stefanmuke Jun 06 '18 at 16:49
  • 1
    Ops! sorry about that, I think you are looking for `StreamBuilder`: https://stackoverflow.com/questions/46611369/get-all-from-a-firestore-collection-in-flutter – Blasanka Jun 06 '18 at 16:54
  • That's it, thanks a lot! – stefanmuke Jun 06 '18 at 19:34

1 Answers1

1

There is an example of doing this using a StreamBuilder at https://pub.dartlang.org/packages/cloud_firestore#-example-tab-

Wm Leler
  • 231
  • 2
  • 4
  • 2
    The example has moved to the [read me](https://pub.dartlang.org/packages/cloud_firestore#-readme-tab-) tab, the example tab is (currently) surprisingly empty. – Abby Jan 22 '19 at 20:06