addListener method

Future<bool> addListener(
  1. EventListen eventListen
)

第三步 添加消息流监听 Step 3: add message flow listening

Implementation

Future<bool> addListener(EventListen eventListen) async {
  if (!_supportPlatform) return false;
  if (_eventChannel != null && _stream != null) {
    if (_streamSubscription != null) return false;
    try {
      _streamSubscription = _stream!.listen(eventListen);
      return true;
    } catch (e) {
      debugPrint(e.toString());
      return false;
    }
  }
  return false;
}