state property

  1. @protected
  2. @visibleForTesting
Wallet? get state
inherited

The current "state" of this StateNotifier.

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

@protected
@visibleForTesting
T get state {
  assert(_debugIsMounted(), '');
  return _state;
}
  1. @protected
  2. @visibleForTesting
set state (Wallet? value)
inherited

Implementation

@protected
@visibleForTesting
set state(T value) {
  assert(_debugIsMounted(), '');
  final previousState = _state;
  _state = value;

  /// only notify listeners when should
  if (!updateShouldNotify(previousState, value)) {
    return;
  }

  _controller?.add(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!(error, stackTrace);
      } else {
        Zone.current.handleUncaughtError(error, stackTrace);
      }
    }
  }
  if (errors.isNotEmpty) {
    throw StateNotifierListenerError._(errors, stackTraces, this);
  }
}