addListener method
第三步 添加消息流监听 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) {
await _streamSubscription!.cancel();
_streamSubscription = null;
}
try {
_streamSubscription = _stream!.listen(eventListen);
return true;
} catch (e) {
debugPrint(e.toString());
return false;
}
}
return false;
}