flutter_dynamic_forms
flutter_dynamic_forms copied to clipboard
MutableProperty ignoreLastChange
Hi! i found some bug in MutableProperty
setValue
function, maybe it's not a bug, i dont know 😄
Problem what i need force update value, because i listen this value in difrent places, but trigger ignoreLastChange
don't usese in void setValue
. I have not found ignoreLastChange
in the code where this trigger is used, is it a logical mistake?
solution 1:
check ignoreLastChange
void setValue(T value, {bool ignoreLastChange = false}) {
_ignoreLastChange = ignoreLastChange;
var oldValue = _cachedValue;
_cachedValue = value;
expression.value = value;
if (ignoreLastChange ? true : _cachedValue != oldValue) {
valueChangedSubject?.add(_cachedValue);
notifySubscribers();
}
}
solution 2:
add trigger force
void setValue(T value, {bool ignoreLastChange = false, bool force = false}) {
_ignoreLastChange = ignoreLastChange;
var oldValue = _cachedValue;
_cachedValue = value;
expression.value = value;
if (force ? true : _cachedValue != oldValue) {
valueChangedSubject?.add(_cachedValue);
notifySubscribers();
}
}
First variant looking better.