'Flutter: Output and Record information of checkboxes in StreamBuilder
How do I output checkboxes for every item returned in a Streambuilder and also record that information to do something with it later? I do not know how many items will be outputted and so I have no idea how many variables I should use to check the status of checkboxes. I also attached a rudimentary UI to sketch what I want the streambuilder to look like and record. Note: I am currently in a stateless widget, however, I can change it to stateful if necessary
Code to StreamBulder
StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection("children")
.where("parentUID",
isEqualTo: FirebaseAuth
.instance.currentUser!.uid)
.orderBy('timestamp',
descending: true)
.snapshots(),
builder: (BuildContext context,
AsyncSnapshot<QuerySnapshot>
snapshot) {
if (snapshot.hasError) {
return const Text(
'Something went wrong');
}
if (snapshot.connectionState ==
ConnectionState.waiting) {
return const Text("Loading");
}
return Column(
children: snapshot.data!.docs.map(
(DocumentSnapshot document) {
Map<String, dynamic> data =
document.data()!
as Map<String, dynamic>;
return Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
/*Output a checkbox for every result returned and name its title 'data['childUserName']'. Then, I want to be able to record the responses of those checkboxes and save them when I run a function.*/
],
);
},
).toList(),
);
},
),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


