-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A ScrollController was used after being disposed. #350
Comments
Hi, Thank you for reporting this bug, and sorry for being unresponsive due to holiday slow-down time. Would you have time to debug with me? I suspect that the bug could be caused by this line: void _resetScrollControllers() {
_scrollControllers.clear();
_scrollControllers = [
for (int i = 0; i < _pagesCount; i++)
(_page.scrollController ??
ScrollController(initialScrollOffset: _scrollPositions[i].value)),
];
} this should have been: (widget.pages[i].scrollController ??
ScrollController(initialScrollOffset: _scrollPositions[i].value)), WDYT? |
Hi. No problem :) I just tried your idea but it's not enough, controller is still getting disposed, in dispose() of WoltModalSheetAnimatedSwitcher. The workaround I used for debugging: Added a bool to _scrollControllers to keep track of which ones should be autodisposed by WoltModalSheetAnimatedSwitcher dispose().
Created a method _currentPageScrollPositionChanges for adding and removing position Listener.
It works if I enable isTopBarLayerAlwaysVisible, which is fine for my case.
|
Bug report
Describe the bug
Hello. Thank you for sharing your amazing work.
When providing a ScrollController to a SliverWoltModalSheetPage, when resizing window (tested on desktop/Windows), this error happens: "A ScrollController was used after being disposed."
Because I guess WoltModalSheetAnimatedSwitcher disposes _scrollControllers.
Am I doing something wrong, or is it a bug?
I'm using a workaround (I modified WoltModalSheetAnimatedSwitcher), in dispose(), by disposing only if scrollcontroller is "internal", and if external, removing its position listener (recreated by _subscribeToCurrentPageScrollPositionChanges).
For the moment it only works if I use a topbar (but this does the job for the moment as I'm using a topbar).
I'll try to dig in package to better understand how everything works, but you probably have a better idea how to fix it than me :)
Thank you in advance for your help.
Steps to reproduce
Steps to reproduce the behavior:
Expected behavior
When providing an external ScrollController to a SliverWoltModalSheetPage, we should be responsible of disposing it.
Additional context
I stumbled on this error while I wanted to programmatically scroll to end of the list (for example when receiving an api event, adding an element + scrolling to end).
The text was updated successfully, but these errors were encountered: