sync method
void
sync(
- T? state
Updates the shared state and notifies all displays.
This method:
- Updates the local state
- Notifies local listeners via notifyListeners
- Propagates the change to all other Flutter engines
If the new state equals the current state, no update occurs.
@param state The new state value, or null to clear
Implementation
void sync(T? state) {
if (_state == state) return; // Avoid unnecessary updates
_state = state;
debugPrint('[SharedState] Syncing state for $_type: $state');
notifyListeners();
SharedStateManager.instance.updateState(_type, toJson(state));
}