windowsQueuePrinter function

Printer windowsQueuePrinter({
  1. required String name,
  2. required String port,
  3. required int status,
  4. required int attributes,
})

The Printer for one installed Windows queue, typed by its port. PDF, fax, file, COM and LPT queues have no connection type.

Implementation

Printer windowsQueuePrinter({
  required String name,
  required String port,
  required int status,
  required int attributes,
}) {
  final upperPort = port.toUpperCase();
  ConnectionType? type;
  if (upperPort.startsWith('USB')) {
    type = ConnectionType.USB;
  } else if ((attributes & _attributeNetwork) != 0 ||
      upperPort.startsWith('IP_') ||
      upperPort.startsWith('WSD') ||
      upperPort.startsWith(r'\\') ||
      _ipPort.hasMatch(upperPort)) {
    type = ConnectionType.NETWORK;
  }
  return Printer(
    name: name,
    address: name,
    vendorId: name,
    productId: 'N/A',
    connectionType: type,
    deviceUri: port,
    queueName: name,
    isConnected:
        (status & (_statusPaused | _statusOffline | _statusNotAvailable)) ==
            0 &&
        (attributes & _attributeWorkOffline) == 0,
  );
}