Closed git-n-pissed closed 1 year ago
The opened state of speed dial gets build once so it will not be affected but as I know someone did created a PR for implementing childrenBuilder of something like that, using that this can be solved.
Check out onOpenBuilder
property, you will get a idea of how to do that.
Imagine a stateful widget in which we want to have a button for "select all" and a button for "deselect all". With the
IconButton
widget I would do it like this:This code sets the
onPressed
property tonull
if the function the button performs doesn't make sense for the parent widget's current state. For example, if_selected.isEmpty
istrue
, there is nothing to deselect, so the button should show as disabled. TheIconButton
widget automatically shows a button as disabled if itsonPressed
property isnull
.If I try to apply the same logic to any aspect of
SpeedDial
orSpeedDialChild
, no rebuild ever takes place. To make a rebuild take place I have to put the state based logic outside ofSpeedDial
and create a whole new instance ofSpeedDial
and its childern. Unfortunately the combination of button states I have makes such a work around untenable.