'Get Firebase Document within ListView Builder

I got a list of questions. When the user doesn't like the question, it can be added to a hidden list. Now I would like list all the questions which have been added to the hidden list.

The Firestore IDs are added to an array within a provider (setting).

When I build the ListView I want to fetch the question documents by document id and pass those document fields to the HiddenList widget.

I've tryied using StreamBuilder, Future,.. unfortunately nothing worked so far.. Any pointers?

Code:

var questions = FirebaseFirestore.instance.collection('questions');
if (setting.hidden.length == 0) {
  return Text('Empty');
} else {
  return ListView.builder(
    scrollDirection: Axis.vertical,
    shrinkWrap: true,
    itemCount: setting.hidden.length,
    itemBuilder: (context, index) {
      return new StreamBuilder(
          stream: questions.doc('${setting.hidden[index]}').snapshots(),
          builder: (context, docSnapshot) {
            if (!docSnapshot.hasData) {
              return Center(child: CircularProgressIndicator());
            } else {
              var data = docSnapshot.data!;
              return HiddenList(
                de_du: data['de_du'],
                de_sie: data['de_sie'],
                de_ich: data['de_ich'],
                en: data['en'],
                id: setting.hidden[index],
              );
            }
          });
    },
  );
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source