Closed dvlj closed 4 years ago
I think that the error comes because you are calling setstate() while the building process. Try to avoid this. Maybe the LayoutBuilder can help you.
Actually, I can call setState() in this code without problem, but when i add SolidController.show() and hide(), it shows error, there must be some kind of conflict between setState and show/hide.
I have the same issue here when using show or hide.
Sorry Folks, but I can't reproduce this error for the moment. I will keep trying to fix it.
Hi there! I have released a new version which includes an improvement on the internal behaviour of the solid bottom sheet. Could you please update your package and tell me if the issue is fixed? Thanks!
I am currently having the same issue, in onShow & onHide I am attempting to setState(() {}) to a value, however it gives the following error:
════════ Exception caught by foundation library ════════════════════════════════ The following assertion was thrown while dispatching notifications for SolidController: setState() or markNeedsBuild() called during build.
Could you please be more especific and explain me when is the exception thown? I will have a look this weekend
onShow() {
this.setState(() {
topPadding = 20.0;
});
}
I had something like the above code, and everytime the onShow was called it occurred.
The problem is that solid bottom sheet calls the setState by itself, so your code is calling also setState and it throws an exception. A solution that I've found is using streams and streamBuilder widgets. I will add two streams for listening solid bottom sheet's height and visibility and depending on the values you should use one "state" or other on your application.
hi, can i set a starting height? then set minHeight to 0?
Hello @immobilizer9 Right now you can't set an initial height when the Solid Bottom Sheet widget is created, however you can try to set the height using the SolidController for the moment. I'll try to add a field on the constructor to set the initial height on the next release. I think that could be interesting to have.
@dbenitez-bcn Thanks for the update! Could you guide me how to use the SolidController to set the initial height? I'm new to this. Thanks again!
You have to create a SolidController SolidController solidController = SolidController();
and then pass it to your SolidBottomSheet widget like this
SolidBottomSheet(controller: solidController, /* your other props here */)
and just do solidController.height = 100;
and if I did it fine it will change the height automatically.
Thanks! Will try it and post an update @dbenitez-bcn
It did set the height to 100 but does not go back down to 0 @dbenitez-bcn
You can use the controller to hide it again
flutter: phase only if one of its ancestors is currently building. This exception is allowed because the flutter: framework builds parent widgets before children, which means a dirty descendant will always be flutter: built. Otherwise, the framework might not visit this widget during this build phase. flutter: The widget on which setState() or markNeedsBuild() was called was: flutter: SolidBottomSheet flutter: The widget which was currently being built when the offending call was made was: flutter: _InheritedResetNotifier
sample code: