I am working on an app and I'd like to display the events that are stored in MongoDB using my GraphQL end points. This is how I do it:
List appointments = Query(
options: QueryOptions(document: gql(_getEvents)),
builder: (result, {fetchMore, refetch}) {
if (result.isLoading) {
return const CircularProgressIndicator();
} else {
result.data!["events"];
}
throw const Text('Something happened');
}) as List;
return _DataSource(appointments);
}
However, I get an error saying that 'The type 'Query is not a subtype of type 'List' in type cast'. Apparently flutter doesn't like that I cast Query as List. The question is 'Is there a way to make the cast work'? Or is there any other applicable workaround?
Thank you in advance