如何使用 Flutter graphql 在 flutter ListView 中加载更多内容

fre*_*hme 5 dart graphql flutter

我需要你的帮助。

我的第一个查询结果是使用 ListView 小部件显示的。我调用 fetchMore 函数(来自 graphql_flutter)以获得更多结果。但它似乎刷新了整个小部件,而不是仅仅在 ListView 底部添加新结果。(它显示正在加载小部件)

我对 Flutter 很陌生。

这是查询小部件中的构建器。

builder: (QueryResult result,                                                                                                                                                                                                                                                  
              {VoidCallback refetch, FetchMore fetchMore}) {                                                                                                                                                                                                                             
            if (result.hasException) {                                                                                                                                                                                                                                                   
              return Text(result.exception.toString());                                                                                                                                                                                                                                  
            }                                                                                                                                                                                                                                                                            
            if (result.loading) {                                                                                                                                                                                                                                                        
              return Center(                                                                                                                                                                                                                                                             
                child: CircularProgressIndicator(),                                                                                                                                                                                                                                      
              );                                                                                                                                                                                                                                                                         
            }                                                                                                                                                                                                                                                                            

            List items = result.data['playlistItems']['items'];                                                                                                                                                                                                                          

            String token = result.data['playlistItems']['nextPageToken'];
            token = token ?? "";

            FetchMoreOptions opts = FetchMoreOptions(
                variables: {'nextPageToken': token},
                updateQuery: (previousResultData, fetchMoreResultData) {
                  final List<dynamic> newItems = [
                    ...previousResultData['playlistItems']['items']
                        as List<dynamic>,
                    ...fetchMoreResultData['playlistItems']['items']
                        as List<dynamic>
                  ];

                  fetchMoreResultData['playlistItems']['items'] = newItems;
                  return fetchMoreResultData;
                });

              return Stack(
                children: <Widget>[
                  VideoList(itemCount: items.length, items: items),
                  Align(
                    alignment: Alignment.bottomRight,
                    child: Padding(
                      padding: EdgeInsets.symmetric(
                          vertical: 10.0, horizontal: 10.0),
                      child: FloatingActionButton.extended(
                        onPressed: () {
                          fetchMore(opts);
                        },
                        label: Text("Load More"),
                        icon: Icon(Icons.more),
                      ),
                    ),
                  ),
                ],
              );
Run Code Online (Sandbox Code Playgroud)

如何在列表底部添加获取更多结果而不是刷新整个列表视图?

我缺少什么?