The ValueBuilder and ObxValue Widgets
Learn to handle a widget’s local state with ValueBuilder and ObxValue.
Introduction
ValueBuilder
and ObxValue
are stateful widgets that control the local state of the widget they wrap around. Consider we have a switch; we can control its toggle state simply by wrapping it with one of these widgets. There is no need to create a variable or a toggle method with setState
. This helps us classify the code for widgets whose state can be defined by a single variable.
ValueBuilder
ValueBuilder
is a local state manager that defines a widget’s state using a single variable and provides the mechanism to update it. If the variable’s value changes, it updates the state and rebuilds the widget.
Let’s look at its syntax:
Get hands-on with 1400+ tech skills courses.