Last active
November 19, 2018 06:15
-
-
Save 5lineofcode/203c4cb3938a2d62ef6e26e3d3994cd4 to your computer and use it in GitHub Desktop.
Firebase Flutter Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getDataListen() { | |
CollectionReference reference = Firestore.instance.collection('jobs'); | |
reference.snapshots().listen((querySnapshot) { | |
List<Joblist> todoList = List<Joblist>(); | |
for (int i = 0; i < querySnapshot.documents.length; i++) { | |
todoList.add(Joblist.fromMap(querySnapshot.documents[i])); | |
} | |
setState(() { | |
joblist = todoList; | |
}); | |
}); | |
listenFirebase() { | |
Firestore.instance | |
.collection('message') | |
.where("user", isEqualTo: "Deny") | |
.snapshots() | |
.listen( | |
(data) => data.documents.forEach((doc) => print(doc["message"]))); | |
} | |
createData() { | |
Firestore.instance | |
.collection('books') | |
.document() | |
.setData({'title': 'title', 'author': 'author'}); | |
} | |
removeData() { | |
Firestore.instance | |
.collection('books') | |
.document('-LNWoNygtcsNXrLz0Y_c') | |
.delete(); | |
print("Data deleted!"); | |
} | |
getData(key){ | |
DocumentSnapshot doc = | |
await Firestore.instance.collection('order').document(key).get(); | |
item.email = doc["email"]; | |
item.firstName = doc["first_name"]; | |
item.lastName = doc["last_name"]; | |
item.username = doc["username"]; | |
item.billing = doc["billing"]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment