updateState method
void
updateState(
- T newState
Updates the state and notifies listeners if the value has changed
Implementation
void updateState(T newState) {
_checkDisposed();
// Skip if state hasn't changed
if (_data.hashCode == newState.hashCode) {
assert(() {
log('''
ℹ️ ViewModel<${T.toString()}> update skipped - state unchanged
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ID: $_instanceId
Hash: ${_data.hashCode}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
''', level: 5);
return true;
}());
return;
}
_data = newState;
_updateCount++;
notifyListeners();
assert(() {
log('''
📝 ViewModel<${T.toString()}> updated
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ID: $_instanceId
Update #: $_updateCount
New state hash: ${_data.hashCode}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
''', level: 10);
return true;
}());
}