Open Sam-Guru-In-Training opened 2 years ago
@Sam-Guru-In-Training hi, did you solve this issue?
I found a way to make it work, with some kind kind guidance. But still, it would be cool to have it as a bool to keep the code cleaner and more easily readable. A 'resetScrollPositionOnPanelClosed' boolean property.
@Sam-Guru-In-Training after some researches i found Pull request where exactly this issue was fixed, here: https://github.com/willbryant/sliding_up_panel/tree/master and just changed in pubspec.yaml to this repo
@Sam-Guru-In-Training what was the way?
I had a great deal of help from Stackoverflow to solve it.
The answer is here
The SlidingUpPanel Widget panelBuild method requires a ScrollController. I had to copy this to _scrollController, so I can use it outside Panel's build in the pages build() method.
panelBuilder: (ScrollController sc) {
// ! So we can use local scrollcontroller outside the panel builder
_scrollController ??= sc;
return ScrollingList(
scrollController: _scrollController!,
);
2 further functions were create to administer _scrollController's state from the App's build() method.
These were called from the app Drawer I think, to close the SlidingUpPanel. And also from interaction with a close panel widget, at the top of the SlidingUp Panel.
Describe the bug My panel has a ListView, with a ScrollController attached. If I use the ScrollController passed through from panelBuilder like:
panelBuilder: (slideUpPanelScrollController) =>
Then scrolling will function correctly, I can scroll the ListView to the top, then the panel will begin scrolling down revealing the background.
However I need to switch the panel content when the user selects items from the appDrawer.
When the user selects a new item from the AppDrawer I need to ensure the panel's refreshed ListView starts at
.jumpTo(0)
, the top.So I use a global ScrollController to control the panel's Listview.
This solves the problem when offering a peek at the ListView - having it a fifth opened on an AppDrawer menu item select, but creates a bug when closing. The ListView scrolls up as the Panel draws down. Not what the user expects, and a lousy experience.
If I do it as per the instruction, well when you force close the panel, using slidingPanelController.close(), well it doesn't automatically jump the panel's ListView controller to the top. So if I open a content refreshed panel, it can open midway down.
It would be great if slidingPanelController.close() also jumped the panel's ScrollController to the top, or if there was a recommended way to deal with this scenario.