0

I have a stream Builder that collect data from firestore. sometimes with the new user can happen that some fields are still missing because of a new user. I am trying this way: ${snapshot.data.docs[index]['review'] ?? 'No data available'} but nothing returns error it doesnt work. here the full code:

StreamBuilder( stream: FirebaseFirestore.instance.collection('Consultant').snapshots(), builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) { return ListView.builder( padding: EdgeInsets.fromLTRB(5, 0, 0, 60), itemCount: snapshot.data.docs.length, itemBuilder: (BuildContext context, int index) { final profile = snapshot.data.docs; return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( snapshot.data.docs[index]['nickName'], 

I just want to substite the field if it is missing or null

9
  • please add some code snippet if possible ? Commented Dec 21, 2020 at 14:42
  • Text( snapshot.data.docs[index]['review'].toString() == null || snapshot.data.docs[index]['review'].toString() == "" ? "No Data Available" : snapshot.data.docs[index]['review'].toString() ), Commented Dec 21, 2020 at 14:54
  • you can try this may be it will work Commented Dec 21, 2020 at 14:54
  • No it doesnt work Commented Dec 21, 2020 at 15:40
  • 1
    please add some code snippet so more clear Commented Dec 21, 2020 at 15:47

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.