Issue
i wanna add a data.value() from Firebase Firestore items in a List,
i got 10 Item in Firestore Array, and all items will be showed in List ,
here im getting the Doc as ,
docCek() {
firestoreInstance.collection("icerik").doc("TYT").get().then((value) {
//print(value.data());
int itemCount = value.data()!["dersler"].length;
});
update();
}
result is :
I/flutter (11270): [Türkce, Matematik, Geometri, Fizik, Kimya, Biyoloji, Tarih, Cografya, Felsefe, Din Kültürü]
and i got a Local RxList , i wanna add all items in List with for , but for Loop is not going ,
var dersler = [].obs;
and my Function with For Loop
docCek() {
firestoreInstance.collection("icerik").doc("TYT").get().then((value) {
//print(value.data());
print(value.data()!["dersler"]);
print(value.data()!["dersler"].length);
int count = value.data()!["dersler"].length;
for (var i = 0; i >= count; i++) {
dersler.add(value.data()!["TYT"]);
print(dersler.toString());
}
});
update();
}
how can i add all items from result to dersler List ?
Thanks !
Solution
I got it right now, i add only addAll Function and here is the new Code ,
docCek() {
firestoreInstance.collection("icerik").doc("TYT").get().then((value) {
//print(value.data());
print(value.data()!["dersler"]);
print(value.data()!["dersler"].length);
int count = value.data()!["dersler"].length;
dersler.addAll(value.data()!["dersler"].toList());
/* for (var i = 0; count > i; i++) {
dersler.addAll(value.data()!["dersler"].toString());
print(dersler.toString());
}*/
});
update();
}
Answered By - Koek
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.