ScrollController not attached to any scroll views

前端 未结 11 1163
难免孤独
难免孤独 2021-01-17 07:22

I\'m using CustomScrollView, and providing it with a controller. ScrollController works, I even added a listener to it and print out the position of the scroll view.

11条回答
  •  迷失自我
    2021-01-17 08:09

    I found working solution, but frankly the method is not best practice, I suppose. In my case controller.jumpTo() was called before it was attached to any scroll view. In order to solve problem I delayed some milliseconds and then call .jumpTo(), because build will be called and controller will be attached to any scroll view.

    Future.delayed(Duration(milliseconds: ), () {
             _scrollController.jumpTo(50.0);
            });
    

    I full agree that it is bad solution, but It can solve problem.

提交回复
热议问题