logChange static method

void logChange({
  1. required String providerId,
  2. required String newValue,
  3. String? previousValue,
  4. String? description,
})

Log a state change.

Implementation

static void logChange({
  required String providerId,
  required String newValue,
  String? previousValue,
  String? description,
}) {
  final provider = _providers[providerId];
  if (provider == null) return;

  final change = StateChange(
    id: '${providerId}_${++_idCounter}',
    providerName: provider.name,
    previousValue: previousValue ?? provider.currentValue,
    newValue: newValue,
    timestamp: DateTime.now(),
    stateType: provider.stateType,
    description: description,
  );

  // Update provider
  provider.currentValue = newValue;
  provider.changeCount++;

  // Add to changes list
  _changes.insert(0, change);
  if (_changes.length > maxChanges) {
    _changes.removeRange(maxChanges, _changes.length);
  }

  // Notify listeners
  _notifyListeners(change);
}