在网页浏览量中:-有时在滑动时itemBuilder被调用2-3次

时间:2019-11-02 10:18:42

标签: flutter flutter-layout flutter-test

这是我的代码:-

PageView.builder(
                          scrollDirection: Axis.vertical,
                          key: PageStorageKey('player_home'),
                          itemBuilder: (context, position) {
                            return VideoPlayerSurfaceNew(
                              key: PageStorageKey('page-$position'),
                              currentWave: state.userFeedDbList[position],
                              videoPlayerController: videoPlayerController,
                              videoPlayerControllerCallBack:
                                  videoPlayerControllerCallBack,
                            );
                          },
                          itemCount: state.userFeedDbList.length,
                          controller: _myPageViewController,
                          onPageChanged: (page) {

                          },
                        ),

这是我的控制器

_myPageListener() {
if (_myPageViewController.offset >=
        _myPageViewController.position.maxScrollExtent &&
    !_myPageViewController.position.outOfRange) {
  _userFeedBloc.dispatch(LoadUserFeedNextPage());
  _userFeedDbBloc.dispatch(LoadUserFeedDb());
}
}

在我向上或向下滑动时多次调用此itembuilder。

0 个答案:

没有答案