addListener static method

int? addListener(
  1. Function? onEvent
)

添加监听器 返回id, 用于删除监听器使用

Implementation

static int? addListener(Function? onEvent) {
  //event channel 注册
  _subscription ??= eventChannel.receiveBroadcastStream('init').listen(_onEvent, onError: _onError);

  if (onEvent != null) {
    _events[onEvent.hashCode] = onEvent;
    getCurrentVolume.then((value) {
      onEvent(value);
    });
    return onEvent.hashCode;
  }
  return null;
}