You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I designed my own TapAndHoverButton (a stateful widget) and pass a color to it. On tap, the color of the button should change but it doesn't. This mini example shows that the color of the Text changes as expected but the button color doesn't. Why?
Your TapAndHoverButton is not using the color value that you're passing in. You don't need to manually pass in any of those variables into the createState() override. Once inside _TapAndHoverButtonState you access all variables that you're trying to pass in with widget.yourVariable. For the color to change in your button all you need to do is set the color in the BoxDecoration to widget.color and you'll get expected behavior from GetX because it is definitely rebuilding when it's supposed to.
Also if you wanted to you could lose the colorMap entirely and just pass in controller.colorKey.value ? Colors.red : Colors.blue to the color properties.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I designed my own TapAndHoverButton (a stateful widget) and pass a color to it. On tap, the color of the button should change but it doesn't. This mini example shows that the color of the Text changes as expected but the button color doesn't. Why?
Beta Was this translation helpful? Give feedback.
All reactions