Skip to content

Instantly share code, notes, and snippets.

@vijayinyoutube
Last active September 14, 2021 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijayinyoutube/d0b033abb566b84c2c78325df35187ed to your computer and use it in GitHub Desktop.
Save vijayinyoutube/d0b033abb566b84c2c78325df35187ed to your computer and use it in GitHub Desktop.
class FireStoreDataBase {
List studentsList = [];
final CollectionReference collectionRef =
FirebaseFirestore.instance.collection("Students");
Future getData() async {
try {
//to get data from a single/particular document alone.
// var temp = await collectionRef.doc("<your document ID here>").get();
// to get data from all documents sequentially
await collectionRef.get().then((querySnapshot) {
for (var result in querySnapshot.docs) {
studentsList.add(result.data());
}
});
return studentsList;
} catch (e) {
debugPrint("Error - $e");
return e;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment