Ritwik Reddy
Ritwik Reddy

Reputation: 11

Good use of refetch for ListView with graphql_flutter

This is my query

Query(
            options: QueryOptions(
                document: gql(query),
                variables: {
                  'startIndex': startIndex,
                  'endIndex': startIndex + 50
                },
                fetchPolicy: FetchPolicy.cacheAndNetwork,
            ),
            builder: (
                QueryResult result, { VoidCallback refetch, FetchMore fetchMore }
                )
            {
              if (result.data == null){
                refetch();
                print('data is null');
              }
              startIndex = repositories.length;
              print(startIndex);
              return ListView.builder();

everytime I reload the page, it is showing

result: null

when print(result);

Then I added refetch() if result is null. Now it is showing

Query is not refetch safe I used graphql_flutter ^5.0.0

Upvotes: 1

Views: 1021

Answers (0)

Related Questions