в просмотре страницы: - иногда itemBuilder вызывается 2-3 раза при пролистывании - PullRequest
0 голосов
/ 02 ноября 2019

вот мой код: -

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

в этом итебилдере много раз вызывался, когда я проводил ВВЕРХ или ВНИЗ.

...