useValueChanged<T, R> function
R?
useValueChanged<T, R>(
- T value,
- R? valueChange(
- T oldValue,
- R? oldResult
What valueChange returned the last time value changed: null in the
first build, then, in each build whose value is not equal to the last
one's, valueChange of the last value and of what it returned before.
Which way the selection moved last:
HookBuilder(
builder: (context) {
final direction = useValueChanged<int, String>(
selected,
(old, _) => selected > old ? 'down' : 'up',
);
return Text('moved ${direction ?? 'nowhere'}');
},
)
Implementation
R? useValueChanged<T, R>(
T value,
R? Function(T oldValue, R? oldResult) valueChange,
) => use(_ValueChangedHook(value, valueChange));