state property

AsyncValue<T> state

The current "state" of this AsyncNotifier.

Updating this variable will synchronously call all the listeners. Notifying the listeners is O(N) with N the number of listeners.

Updating the state will throw if at least one listener throws.

Implementation

AsyncValue<T> get state {
  return _state;
}
void state=(AsyncValue<T> value)

Implementation

set state(AsyncValue<T> value) {
  _state = 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 (errors.isNotEmpty) {
    throw NotifierListenerError._(errors, stackTraces, this);
  }
}