dispose method Null safety

Future<bool> dispose()

关闭并销毁消息通道 Close and destroy the message channel

Implementation

Future<bool> dispose() async {
  assert(_channel != null, 'You must call setMethodChannel() first');
  if (!_supportPlatform || _channel == null) return false;
  await _streamSubscription?.cancel();
  _streamSubscription = null;
  _stream = null;
  _eventChannel = null;
  final bool? state = await _channel!.invokeMethod<bool>('stopEvent');
  return state ?? false;
}