sliding_up_panel
sliding_up_panel copied to clipboard
Can you add an optional parameter as position to PanelState.OPEN, or add another state PanelState.PARTIALLY_OPEN({int position})?
The requirement is user should be able to see sliding_panel
opened by default, not to maxHeight but to a specific position. However, later on, the user can drag the panel within maxHeight and minHeight.
Tried several ways to accomplish this,
- Initially kept
defaultPanelState
as CLOSED and tried overridingonPanelClosed
to change the panel position by the controller with one time check, howeveronPanelClosed
callback only triggers when the user interacts with the panel for the first time. - Used
setState
for this widget to increase themaxHeight
as soon as it is rendered. This solves the issue but the max height change transition experienced by the user is not smooth, it jumps to the maxHeight.
Even if there is any other clean way already available to achieve it, please share that as well.
You can use animatePanelToPosition method available on the panel controller.
animatePanelToPosition(double value, {Duration duration, Curve curve = Curves.linear})
Attach this to to a postframe callback so it gets called after the UI is built.
late final panelController;
void initState() {
super.initState();
panelController = PanelController();
WidgetsBinding.instance.addPostFrameCallback((_) =>
panelController.animatePanelToPosition(yourPosition, duration: Duration(milliseconds: 0))
);
}