Reputation: 11
I have copied this code from the graphql_flutter pub.dev page still getting this error when I hover over the builder. All I did is put in my query and changed some values inside the builder that relates to my query.
Error - The argument type 'StatelessWidget Function(QueryResult, {Future Function(FetchMoreOptions) fetchMore, void Function() refetch})' can't be assigned to the parameter type 'Widget Function(QueryResult, {Future Function(FetchMoreOptions)? fetchMore, Future<QueryResult?> Function()? refetch})'.
final String _query = """
query {
users {
id
name
email
}
} """;
@override
Widget build(BuildContext context) {
return Query(
options: QueryOptions(
document: gql(_query), // this is the query string you just created
pollInterval: Duration(seconds: 10),
),
builder: (QueryResult result, {VoidCallback refetch, FetchMore fetchMore}) {
if (result.hasException) {
return Text(result.exception.toString());
}
if (result.isLoading) {
return Text('Loading');
}
List repositories = result.data['users'];
return ListView.builder(
itemCount: repositories.length,
itemBuilder: (context, index) {
final repository = repositories[index];
return Text(repository['name']);
});
},
);
}
}```
Upvotes: 1
Views: 138
Reputation: 457
builder: (QueryResult result, {
Future<QueryResult> Function(FetchMoreOptions)? fetchMore,
Future<QueryResult?> Function()? refetch,
}) {
Updating the builder function syntax to match the 'parameter type' works.
Upvotes: 1