Neha Bhardwaj
Neha Bhardwaj

Reputation: 1393

how to retrieve the data from cloud Firestore in flutter?

We are trying to fetch the data from cloud Firestore but we unable to find that how admin fetch all the information about user like their appointment

enter image description here

enter image description here

Upvotes: 0

Views: 2537

Answers (1)

Shyju M
Shyju M

Reputation: 9943

Hope you are using the plugin cloud_firestore to fetch the data from the firestore

initialize the firestore with your credentials which can be copied from your google_services.json file

final FirebaseApp app = await FirebaseApp.configure(
    name: 'test',
    options: const FirebaseOptions(
      googleAppID: '1:79601577497:ios:5f2bcc6ba8cecddd',
      gcmSenderID: '79601577497',
      apiKey: 'AIzaSyArgmRGfB5kiQT6CunAOmKRVKEsxKmy6YI-G72PVU',
      projectID: 'flutter-firestore',
    ),
  );
  final Firestore firestore = Firestore(app: app);

to fetch your documents

  CollectionReference get users=> firestore.collection('users');
  await users.where('name', isEqualTo: 'neha').getDocuments();

or

Firestore.instance.collection('users').where('name', isEqualTo: 'neha')
    .snapshots.listen(
          (data) => print('grower ${data.documents[0]['name']}')
    );

Upvotes: 1

Related Questions