Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firestore queries on Flutter

How can I use the .where() in FlutterFire to perform queries for Firestore? Because the docs and example doesn't cover this I'm confused. I haven't found other questions on this here so I hope I'm not asking duplicate.

like image 560
Tsortanidis Christos Avatar asked Feb 22 '18 21:02

Tsortanidis Christos


People also ask

How do you query data from firestore in Flutter?

You will need to add the list of query options that a user will search for. At the time when you are pushing data into the firestore you can do is to create the search query options. This will result in pushing all the queries that a user can search for.


1 Answers

Example below go through every document in the collection 'fields', and filter on 'grower`. There is no documentation on that, but you may check the source code.

import 'package:cloud_firestore/cloud_firestore.dart';  Firestore.instance.collection('fields').where('grower', isEqualTo: 1)     .snapshots().listen(           (data) => print('grower ${data.documents[0]['name']}')     ); 

From source code:

  Query where(     String field, {     dynamic isEqualTo,     dynamic isLessThan,     dynamic isLessThanOrEqualTo,     dynamic isGreaterThan,     dynamic isGreaterThanOrEqualTo,     bool isNull,   }) {..} 
like image 66
grepLines Avatar answered Oct 11 '22 20:10

grepLines