mount method

  1. @internal
void mount()

Called the first time a provider is obtained.

Implementation

@internal
void mount() {
  _mounted = true;
  assert(
    () {
      _debugCurrentCreateHash = provider.debugGetCreateSourceHash?.call();

      return true;
    }(),
    '',
  );
  buildState();

  _state!.map(
    data: (newState) {
      final onChangeSelfListeners = _onChangeSelfListeners;
      if (onChangeSelfListeners != null) {
        for (var i = 0; i < onChangeSelfListeners.length; i++) {
          Zone.current.runBinaryGuarded(
            onChangeSelfListeners[i],
            null,
            newState.state,
          );
        }
      }
    },
    error: (newState) {
      final onErrorSelfListeners = _onErrorSelfListeners;
      if (onErrorSelfListeners != null) {
        for (var i = 0; i < onErrorSelfListeners.length; i++) {
          Zone.current.runBinaryGuarded(
            onErrorSelfListeners[i],
            newState.error,
            newState.stackTrace,
          );
        }
      }
    },
  );
}