sliding_up_panel
sliding_up_panel copied to clipboard
Set MinHeight of panel to fit content
Hello, is it possible to set the MinHeight of the panel based on content that's being revealed? (Like collapsed except the content in it doesn't fade away on drag up)
any update about this?
Interested in this as well. I got around this by tapping into the build function of the Panel Body and getting the content height at runtime but a less hacky way would be nice.
Yep, I need this one too...
Interested in this as well. I got around this by tapping into the build function of the Panel Body and getting the content height at runtime but a less hacky way would be nice.
Hey, could you please share your code snippet to make this change? I know it's dirty but as maintainer does not update this package, it might be a good solution for me. Thanks!
Interested in this as well. I got around this by tapping into the build function of the Panel Body and getting the content height at runtime but a less hacky way would be nice.
Hey, could you please share your code snippet to make this change? I know it's dirty but as maintainer does not update this package, it might be a good solution for me. Thanks!
Sure, in my PanelContent Widget I add a call like this in the build function:
@override
Widget build(BuildContext context) {
WidgetsBinding.instance
.addPostFrameCallback((_) => onBuildCompleted(context));
...
void onBuildCompleted(BuildContext context) {
if (widget._containerKey.currentContext != null) {
final RenderBox containerRenderBox =
widget._containerKey.currentContext.findRenderObject();
double containerSize = containerRenderBox.size.height;
// only set if it actually changed
if (_lastHeight != containerSize) {
setState(() {
_lastHeight = containerSize;
});
Provider.of<PanelProvider>(context).changePanelHeight(containerSize);
}
}
}
I pass the GlobalKey from the main widget:
GlobalKey _containerKey = GlobalKey();
The SlidingUpPanel then listens for the Provider change and sets
maxHeight
I additionally animated the height change:
@override
void didChangeDependencies() {
controller.reset();
double begin = panelHeight;
double end = Provider.of<PanelProvider>(context).currentPanelHeight;
panelHeightTween.begin = begin;
panelHeightTween.end = end;
setState(() {
panelHeight = end;
});
controller.forward();
super.didChangeDependencies();
}
Interested in this as well. I got around this by tapping into the build function of the Panel Body and getting the content height at runtime but a less hacky way would be nice.
Hey, could you please share your code snippet to make this change? I know it's dirty but as maintainer does not update this package, it might be a good solution for me. Thanks!
Sure, in my PanelContent Widget I add a call like this in the build function:
@override Widget build(BuildContext context) { WidgetsBinding.instance .addPostFrameCallback((_) => onBuildCompleted(context)); ... void onBuildCompleted(BuildContext context) { if (widget._containerKey.currentContext != null) { final RenderBox containerRenderBox = widget._containerKey.currentContext.findRenderObject(); double containerSize = containerRenderBox.size.height; // only set if it actually changed if (_lastHeight != containerSize) { setState(() { _lastHeight = containerSize; }); Provider.of<PanelProvider>(context).changePanelHeight(containerSize); } } }
I pass the GlobalKey from the main widget:
GlobalKey _containerKey = GlobalKey();
The SlidingUpPanel then listens for the Provider change and sets
maxHeight
I additionally animated the height change:
@override void didChangeDependencies() { controller.reset(); double begin = panelHeight; double end = Provider.of<PanelProvider>(context).currentPanelHeight; panelHeightTween.begin = begin; panelHeightTween.end = end; setState(() { panelHeight = end; }); controller.forward(); super.didChangeDependencies(); }
Thanks mate, it helped me! At first, using a provider was a bad approach to me, but couldn't find any other solution.. however it's working pretty well.
Interested in this as well. I got around this by tapping into the build function of the Panel Body and getting the content height at runtime but a less hacky way would be nice.
Hey, could you please share your code snippet to make this change? I know it's dirty but as maintainer does not update this package, it might be a good solution for me. Thanks!
Sure, in my PanelContent Widget I add a call like this in the build function:
@override Widget build(BuildContext context) { WidgetsBinding.instance .addPostFrameCallback((_) => onBuildCompleted(context)); ... void onBuildCompleted(BuildContext context) { if (widget._containerKey.currentContext != null) { final RenderBox containerRenderBox = widget._containerKey.currentContext.findRenderObject(); double containerSize = containerRenderBox.size.height; // only set if it actually changed if (_lastHeight != containerSize) { setState(() { _lastHeight = containerSize; }); Provider.of<PanelProvider>(context).changePanelHeight(containerSize); } } }
I pass the GlobalKey from the main widget:
GlobalKey _containerKey = GlobalKey();
The SlidingUpPanel then listens for the Provider change and sets
maxHeight
I additionally animated the height change:
@override void didChangeDependencies() { controller.reset(); double begin = panelHeight; double end = Provider.of<PanelProvider>(context).currentPanelHeight; panelHeightTween.begin = begin; panelHeightTween.end = end; setState(() { panelHeight = end; }); controller.forward(); super.didChangeDependencies(); }
What does this look like? Any chance of a gif?
Interested in this as well. I got around this by tapping into the build function of the Panel Body and getting the content height at runtime but a less hacky way would be nice.
Hey, could you please share your code snippet to make this change? I know it's dirty but as maintainer does not update this package, it might be a good solution for me. Thanks!
Sure, in my PanelContent Widget I add a call like this in the build function:
@override Widget build(BuildContext context) { WidgetsBinding.instance .addPostFrameCallback((_) => onBuildCompleted(context)); ... void onBuildCompleted(BuildContext context) { if (widget._containerKey.currentContext != null) { final RenderBox containerRenderBox = widget._containerKey.currentContext.findRenderObject(); double containerSize = containerRenderBox.size.height; // only set if it actually changed if (_lastHeight != containerSize) { setState(() { _lastHeight = containerSize; }); Provider.of<PanelProvider>(context).changePanelHeight(containerSize); } } }
I pass the GlobalKey from the main widget:
GlobalKey _containerKey = GlobalKey();
The SlidingUpPanel then listens for the Provider change and setsmaxHeight
I additionally animated the height change:@override void didChangeDependencies() { controller.reset(); double begin = panelHeight; double end = Provider.of<PanelProvider>(context).currentPanelHeight; panelHeightTween.begin = begin; panelHeightTween.end = end; setState(() { panelHeight = end; }); controller.forward(); super.didChangeDependencies(); }
What does this look like? Any chance of a gif?
You have the same sliding sheet as in the examples or reade.me, but the height is simply adapted to the content.
@asiamov Hi, can you please show some full working example? I did not understand where exactly the codes above are used. Thanks in advance
@houdayec
Hello, is it implemented?
Still need this
I think it could be closed, already have
maxHeight: ...
minHeight: ...
I think it could be closed, already have
maxHeight: ... minHeight: ...
Read the issue carefully, basically author want SlidingUpPanel to have minHeight based on content's height, this is like collapsed widget, but it will not fade away while expanding.
IDK I think we're have no chances to resolve this, project is abandoned :smiling_face_with_tear: