I am using SingleChildScrollView and a scrollController to be notified when reaching the end of the scroll view
the SingleChildScrollView component:
Expanded(
child: SingleChildScrollView(
controller: controller.scrollController,
physics: const ScrollPhysics(),
child: Center(
child: Obx(() =>
controller.busy && controller.itemList.isEmpty
? loader
: Column(children: [
listWidget(controller.itemList),
if (controller.busy) loader
]))),
the Listener:
scrollController.addListener(() {
if (scrollController.offset >=
scrollController.position.maxScrollExtent &&
!scrollController.position.outOfRange) {
_next();
}
but for some reason it is calling _next() twice when I am reaching the end of the scroll view and not once as it should.
any idea why? am I doing something wrong?
Use
physics: ClampingScrollPhysics()
in place of
physics: const ScrollPhysics(),
which will clamp the scroll when it reaches the end and will not bounce. The bounce will make the method call twice
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With