I am getting an error with my Streambuilder. I do not understand how to fix it. Please, can you help me to solve this? Many thanks.
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ The following assertion was thrown building StreamBuilder(dirty, state: _StreamBuilderBaseState<QuerySnapshot, AsyncSnapshot>#47274): A build function returned null. The offending widget is: StreamBuilder Build functions must never return null.
StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection('Users')
.doc(FirebaseAuth.instance.currentUser.uid)
.collection('projects')
.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData)
const Text("Loading.....");
else {
List<DropdownMenuItem> projectItems = [];
for (int i = 0; i < snapshot.data.docs.length; i++) {
DocumentSnapshot snap = snapshot.data.docs[i];
projectItems.add(
DropdownMenuItem(
child: Text(
(snap.data()['project_Name']),
style: TextStyle(color: Colors.black),
),
// snap.id,
// style: TextStyle(color: Color(0xff11b719)),
// ),
value: (snap.data()['project_Name']),
),
);
return Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
DropdownButton(
items: projectItems,
onChanged: (projectSelected) {
final snackBar = SnackBar(
content: Text(
'Selected project is $projectSelected',
style: TextStyle(color: Color(0xff11b719)),
),
);
Scaffold.of(context).showSnackBar(snackBar);
setState(() {
selectedProject = projectSelected;
});
},
value: selectedProject,
isExpanded: false,
hint: new Text(
projectName,
style: TextStyle(color: Color(0xff11b719)),
),
),
],
);
}
}
}),