Closed pengboboer closed 1 year ago
I found a solution and it works fine.
I see that the ScrollController in the source code is created like this:
// prevent the panel content from being scrolled only if the widget is
// draggable and panel scrolling is enabled
_sc = new ScrollController();
_sc.addListener(() {
if (widget.isDraggable && !_scrollingEnabled) _sc.jumpTo(0);
});
Then we can extend the PanelController of sliding_up_panel to have the ability to set ScrollController. Add a setScrollController method to PanelController:
void setScrollController(ScrollController sc) {
_panelState!.sc = sc;
}
Then change the ScrollController of the Panel when jumping to another page and returning to the page,like this:
double offset = listController?.offset ?? 0;
panelController.setScrollController(listScrollController);
Navigator.push(...).then((value) {
panelController.setScrollController(detailScrollController);
listController?.jumpTo(offset);
});
This is my demo, if you need it, I hope it can help you.
Describe the bug I have a local route in the sliding panel, and I can jump from a main list to a detail page, which also has a list. When I use PanelBuilder, it will call back a ScrollController to me, but because I have created a local route, there are now two lists in my sliding panel. How can I handle this situation? Can multiple ScrollControllers be provided externally?
zone onError 'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 108 pos 12: '_positions.length == 1': ScrollController attached to multiple scroll views. #0
To Reproduce Steps to reproduce the behavior: There is a local route in the sliding panel that jumps from one page to another. Both pages have a listview and use the panelBuilder's ScrollController, which then throws an exception
Expected behavior Both lists can correctly respond to sliding events. Can PanelBuilder provide multiple ScrollControllers?