value property

T value

The current "value" of this Atom.

Updating this variable will synchronously call all the listeners.

Implementation

T get value {
  assert(_debugIsMounted(), '');

  return _value;
}
void value=(T value)

Implementation

set value(T value) {
  assert(_debugIsMounted(), '');

  _value = value;

  final errors = <Object>[];
  final stackTraces = <StackTrace?>[];
  for (final listenerEntry in _listeners) {
    try {
      listenerEntry.listener(value);
    } catch (error, stackTrace) {
      errors.add(error);
      stackTraces.add(stackTrace);

      if (onError != null) {
        onError?.call(error, stackTrace);
      } else {
        Zone.current.handleUncaughtError(error, stackTrace);
      }
    }
  }
  if (errors.isNotEmpty) {
    throw AtomListenerError._(errors, stackTraces, this);
  }
}