I am only able to provide snippets of my code as this is from a large project.
I have a listbuilder in a page, initially if I tried to scroll the page but happened to be scrolling ontop of the list widget it would only scroll the widget and not the page, what I want is for a user to be able to scroll through the list and then if the the user is at the bottom of the list then scroll the parent page the list is on.
Below are the steps I have taken to try and achieve the desired behaviour, this allows me to scroll the parent page when I over scroll the list, however as soon as I stop dragging and let go it snaps back to the original parent scroll position before the over scroll took place
I have a parent page from which I have declared a scrollController:
final ScrollController _parentScrollController = ScrollController();
Inside the page I assign my controller to the singleChildScrollView of the page:
return SingleChildScrollView(
controller: _parentScrollController,
child: Column(
children: [
// Other widgets
MyListWidget(parentScrollController: _parentScrollController),
// Other widgets
],
),
);
I then parse this to my widget that includes a list builder that has its own controller:
class MyListWidget extends StatelessWidget {
final ScrollController parentScrollController;
MyListWidget({required this.parentScrollController});
@override
Widget build(BuildContext context) {
return Expanded(
child: NotificationListener<ScrollNotification>(
onNotification: (scrollNotification) {
if (scrollNotification is OverscrollNotification) {
final overscroll = scrollNotification.overscroll;
if (overscroll != 0.0) {
final newOffset = parentScrollController.offset + overscroll;
parentScrollController.jumpTo(newOffset);
}
}
return false;
},
child: ListView.builder(
// Add your ListView.builder configuration here
),
),
);
}
}
What am I missing that ensures that the jumpTo actually stays fixed in the parent and prevent the snapback logic