addListener method Null safety

Future<bool> addListener(
  1. CameraEventListen eventListen
)

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

Implementation

Future<bool> addListener(CameraEventListen eventListen) async {
  assert(_channel != null, 'You must call setMethodChannel() first');
  if (!_supportPlatform || _channel == null) 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;
}