ScrollController not attached to any scroll views

前端 未结 11 1172
难免孤独
难免孤独 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 07:50

    I have tried with above solutions but set ScrollController initialScrollOffset, checking hasClients and jumpTo, WidgetsBinding no one is working for me.

    at last solved my problem by checking positions 'scrollcontroller.positions.length' like

    if (_sc.positions.length == 0 || _sc.position.pixels == 0.0) {
        return Container();
    }
    

    You have to check controller positions to get rid of the error

    Reference : https://api.flutter.dev/flutter/widgets/ScrollController/position.html

提交回复
热议问题