Hello guys I need help in this error I tried a lot but nothing is working I am trying to make some notes but because of this error nots are not showing on home screen.
body: StreamBuilder(
stream: _notesService.allNotes(ownerUserId: userId),
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.waiting:
case ConnectionState.active:
if (snapshot.hasData) {
final allNotes = snapshot.data as Iterable<CloudNote>;
return NotesListView(
notes: allNotes,
onDeleteNote: (note) async {
await _notesService.deleteNote(documentId: note.documentId);
},
onTap: (note) {
Navigator.of(context).pushNamed(
createOrUpdateNoteRoute,
arguments: note,
);
},
);
} else {
return const CircularProgressIndicator();
}
default:
return const CircularProgressIndicator();
}
},
),
Please help me in this I will be very thank full.
CodePudding user response:
This error happens whenever you try to pass an Iterable<T>
to something that expects a List<T>
. Based on your code, there are two possible cases:
Try removing the
as Iterable<CloudNote>
(and perhaps changing to aList<CloudNote>
assuming it is one). Ideally, your StreamBuilder should be typed, likeStreamBuilder<List<CloudNote>>
.Change
notes: allNotes,
tonotes: allNotes.toList(),
CodePudding user response:
Change
notes: allNotes
to
notes: allNotes.toList()