akshathjain / sliding_up_panel

A draggable Flutter widget that makes implementing a SlidingUpPanel much easier!
https://pub.dartlang.org/packages/sliding_up_panel
Other
1.38k stars 378 forks source link

Hide panel when collapsed #214

Open rienkkk opened 3 years ago

rienkkk commented 3 years ago

I have a panel and a collapsed widget. When the panel goes to the collapsed state I would like to hide the content of the panel. Right now the panel content shows behind the collapsed widget. Does someone know how to do this?

alestiago commented 3 years ago

I am currently also looking into this. This @akshathjain seems to have done something similar #224 . @akshathjain any comments?

alestiago commented 3 years ago

It seems that if you set minHeight to 0, it will do the job. It is not the most elegant solution, but it is something.

lasd14 commented 2 years ago

@alestiago I try with minHeight: 0 but the result was that my widget dissapear, can you tell me exactly your result with that solution

lasd14 commented 2 years ago

Hi, if someone have the need to hide the panel widget when the panel is closed, because at par you have a collapsed widget and you want to prevent these from overlapping, maybe this code will help you:

First in your Panel Widget you will need to wrap all the widget with a Visibility() and ask for a bool parameter. Second you will declare a bool variable and initialize in true or false. After this you need to have implemented a PanelController.

Okay now in your SlidingUpPanel widget you will use the function onPanelOpened() and onPanelClosed()

onPanelOpened: () { setState(() { visible = true; }); }, onPanelClosed: () { setState(() { visible = false; }); }, panel: _Panel(size: size, visible: visible),

Now when you use open the panel the state visible of the widget will be true and when then panel is closed the state will be false.

I know there may be better solutions for this, but this was the one that solved my problem. Any question can ask me.

Good Luck 🍟