initialize method Null safety

Future<bool> initialize()

第二步 初始化消息通道 Step 2: initialize the message channel

Implementation

Future<bool> initialize() async {
  assert(_channel != null, 'You must call setMethodChannel() first');
  if (!_supportPlatform || _channel == null) return false;
  bool? state = await _channel!.invokeMethod<bool?>('startEvent');
  state ??= false;
  if (state && _eventChannel == null) {
    _eventChannel = const EventChannel('fl.camera/event');
    _stream = _eventChannel?.receiveBroadcastStream(<dynamic, dynamic>{});
  }
  return state && _eventChannel != null && _stream != null;
}