state property

Stream<Web3ModalState> get state

Listens to the Web3Modal state.

Implementation

static Stream<Web3ModalState> get state {
  late StreamController<Web3ModalState> controller;
  late Function? stopListeningFunction;

  void startListening() {
    stopListeningFunction = window.web3modal
        .subscribeState(
          ((PublicStateControllerState state) {
            controller.add(state.toDart);
          }).toJS,
        )
        .toDart;
  }

  void stopListening() {
    stopListeningFunction?.call();
    stopListeningFunction = null;
  }

  controller = StreamController<Web3ModalState>(
    onListen: startListening,
    onPause: stopListening,
    onResume: startListening,
    onCancel: stopListening,
  );

  return controller.stream;
}