sliding_up_panel icon indicating copy to clipboard operation
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})?

Open sdas19 opened this issue 3 years ago • 1 comments

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,

  1. Initially kept defaultPanelState as CLOSED and tried overriding onPanelClosed to change the panel position by the controller with one time check, however onPanelClosed callback only triggers when the user interacts with the panel for the first time.
  2. Used setState for this widget to increase the maxHeight 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.

sdas19 avatar Mar 04 '21 07:03 sdas19

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))
    );
}

arafaysaleem avatar May 08 '21 09:05 arafaysaleem