Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some error on builder graphql #5

Open
Wooody82 opened this issue Mar 26, 2020 · 5 comments
Open

Some error on builder graphql #5

Wooody82 opened this issue Mar 26, 2020 · 5 comments

Comments

@Wooody82
Copy link

Hi,
I just got error when I tried to test the app, I got these error, any way to fix it. Thanks

const Mutation({
^^^^^^^^
lib/src/screens/settings/settings.dart:88:16: Error: The function expression type 'Widget Function(QueryResult, {Future Function() refetch})' isn't of expected type 'Widget Function(QueryResult, {dynamic Function(FetchMoreOptions) fetchMore, Future Function() refetch})'.

  • 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('../../flutter/packages/flutter/lib/src/widgets/framework.dart').
  • 'QueryResult' is from 'package:graphql/src/core/query_result.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/graphql-3.0.0/lib/src/core/query_result.dart').
  • 'Future' is from 'dart:async'.
  • 'FetchMoreOptions' is from 'package:graphql/src/core/query_options.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/graphql-3.0.0/lib/src/core/query_options.dart').
    Change the type of the function expression or the context in which it is used.
    builder: (res, {refetch}) {
    ^
    lib/src/screens/settings/settings.dart:154:7: Error: No named parameter with the name 'onCompleted'.
    onCompleted: (result) async {
    ^^^^^^^^^^^
    ../../flutter/.pub-cache/hosted/pub.dartlang.org/graphql_flutter-3.0.0/lib/src/widgets/mutation.dart:21:9: Context: Found this candidate, but the arguments don't match.
    const Mutation({
    ^^^^^^^^
    lib/src/screens/users/users.dart:160:7: Error: No named parameter with the name 'update'.
    update: (Cache cache, QueryResult result) => cache,
    ^^^^^^
    ../../flutter/.pub-cache/hosted/pub.dartlang.org/graphql_flutter-3.0.0/lib/src/widgets/mutation.dart:21:9: Context: Found this candidate, but the arguments don't match.
    const Mutation({
    ^^^^^^^^
    lib/src/screens/users/users.dart:202:16: Error: The function expression type 'Widget Function(QueryResult, {Future Function() refetch})' isn't of expected type 'Widget Function(QueryResult, {dynamic Function(FetchMoreOptions) fetchMore, Future Function() refetch})'.
  • 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('../../flutter/packages/flutter/lib/src/widgets/framework.dart').
  • 'QueryResult' is from 'package:graphql/src/core/query_result.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/graphql-3.0.0/lib/src/core/query_result.dart').
  • 'Future' is from 'dart:async'.
  • 'FetchMoreOptions' is from 'package:graphql/src/core/query_options.dart' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/graphql-3.0.0/lib/src/core/query_options.dart').
    Change the type of the function expression or the context in which it is used.
    builder: (result, {refetch}) {
    ^
    Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
    build failed.
@shahidAnwarrr
Copy link

I am running with this error if you have found some solution please tell me.

@vineeshvk
Copy link
Owner

vineeshvk commented Jun 8, 2020

Hi, sorry for the late response. I'm not sure what's the problem is. If you have found any solution for that please do post it. And I'm planning to rewrite the whole app using rest API rather than GraphQl.

@vineeshvk
Copy link
Owner

For me there was an issue with flutter and the locked version of graphql. So I had to update the version. And there are many modifications in the API. Maybe that's the reason for the error.

@vineeshvk
Copy link
Owner

I have updated the code now. Now it mostly shouldn't throw any error.

@mohammadwadhodev
Copy link

i resolved this issue and its 100% working just try it

body:Query(
options: QueryOptions(
document: gql(readCountriesQuery)),
builder: (QueryResult result, { VoidCallback? refetch, FetchMore? fetchMore }) {
if (result.hasException) {
return Text(result.exception.toString());
}

        if (result.isLoading) {
          return const Text('Loading');
        }
        if (result.data == null) {
          return const Text('No repositories');
        }

        return ListView.builder(
            itemCount: result.data?['continents'].length,
            itemBuilder: (context, index) {
              var data = result.data?['continents'][index]['name'];
              var code = result.data?['continents'][index]['code'];
              return Card(
                  child: ListTile(
                    leading: Text(code),
                    title: Text(data),
                  ));
            });




      },
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants