connectPrinter method Null safety

  1. @override
Future<bool?> connectPrinter(
  1. PrinterDevice device
)
override

连接打印机 device 打印机设备

Implementation

@override
Future<bool?> connectPrinter(PrinterDevice device) async {
  if (device is BluetoothDevice) {
    return methodChannel.invokeMethod<bool>(
        PluginConstants.methodConnectBluetoothPrinter,
        device.toProto().writeToBuffer());
  }
  if (device is UsbDevice) {
    return methodChannel.invokeMethod<bool>(
        PluginConstants.methodConnectUsbPrinter,
        device.toProto().writeToBuffer());
  }
  if (device is UsbAccessoryDevice) {
    return methodChannel.invokeMethod<bool>(
        PluginConstants.methodConnectUsbAccessoryPrinter,
        device.toProto().writeToBuffer());
  }
  if (device is TcpDevice) {
    return methodChannel.invokeMethod<bool>(
        PluginConstants.methodConnectTcpPrinter,
        device.toProto().writeToBuffer());
  }
  if (device is TtyDevice) {
    return methodChannel.invokeMethod<bool>(
        PluginConstants.methodConnectTtyPrinter,
        device.toProto().writeToBuffer());
  }
  throw UnimplementedError();
}