Flutter function that returns conditional does not give correct result

I have a code like this: //… child: ListTile( leading: CircleAvatar( backgroundImage: NetworkImage("${snapshot.data!.docs[index].data()[‘urunFotografi’]}"), ), title: Text(snapshot.data!.docs[index].data()["urunAdi"], style: TextStyle(fontSize: 20),), subtitle: Text(adetVeyaKilo().toString(), style: TextStyle(fontSize: 15),), ), // … // … Future<String> adetVeyaKilo() async { String state = ""; FirebaseFirestore.instance.collection(‘bolatAktar’).where(‘urunAdi’, isEqualTo: urunAdi).get().then((value) { value.docs.forEach((element) { if (element.data()["urunBirimi"] == "Adet") { state = "Adet"; } if (element.data()["urunBirimi"] ==… Read More Flutter function that returns conditional does not give correct result

Query only specific field with firestore

I use this code to get a collection snapshot from Firestore. firestore().collection(‘project’).where(‘userID’, ‘==’, authStore.uid).onSnapshot(onResult, onError); This returns a huge amount of data, but I only need a few fields. Is it possible to query only a specific field? For example, if I only need the projectName and the creationDate fields. >Solution : Is it possible… Read More Query only specific field with firestore

Add document with auto-generated ID in sub collection?

I’m trying to add a document with auto-generated ID in reviews/something using: await addDoc(collection(dbFirestore, "reviews", route.params.id), { rating: rating, text: text, user: { id: user.id, username: user.username, avatar: user.avatar, }, }); But I get: Invalid collection reference. Collection references must have an odd number of segments, but reviews/XXX has 2. >Solution : Assume reviews is… Read More Add document with auto-generated ID in sub collection?