使用 graphql_flutter 对 ListView 的 refetch 进行很好的使用

问题描述

这是我的查询

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();

每次我重新加载页面时,它都会显示

结果:空

打印时(结果);

然后我添加了 refetch() 如果结果为空。现在显示

查询不是重新获取安全的 我用过 graphql_Flutter ^5.0.0

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)