I am tryiong to display a list of events a user has registered for in a flutter app but i keep getting this error even though I am following the tuorial closely. I believe the error might be in the following lines but I have checked multiple times but havent gotten a fix.
ref.watch(userEventsProvider).when(
data: (events) => Expanded(
child: ListView.builder(
itemCount: events.length,
itemBuilder: (BuildContext context, int index) {
final event = events[index];
return ListTile(
leading: CircleAvatar(
backgroundImage: NetworkImage(event.images),
),
title: Text('/r${event.name}'),
onTap: () {},
);
},
),
),
error: (error, stackTrace) => ErrorText(
error: error.toString(),
),
loading: () => const Loader(),
),
I have tried following the tutorial but theres seems to be no fix.
2
Answers
it seems like the issue might be with the
event.images
field. it’s actually a list of dynamic objects.Replace index with the appropriate index