connect method
Future
connect(
{ - Duration? timeout = const Duration(seconds: 5),
})
override
Implementation
@override
Future connect({Duration? timeout = const Duration(seconds: 5)}) async {
if (Platform.isWindows) {
try {
docInfo = calloc<DOC_INFO_1>()
..ref.pDocName = pDocName
..ref.pOutputFile = nullptr
..ref.pDatatype = pDataType;
szPrinterName = printer.name!.toNativeUtf16();
final phPrinter = calloc<HANDLE>();
if (OpenPrinter(szPrinterName, phPrinter, nullptr) == FALSE) {
return true;
} else {
this.hPrinter = phPrinter.value;
}
} catch (e) {
return Future.error(e.toString());
}
} else if (Platform.isAndroid) {
var usbDevice =
await usbPrinter.connect(printer.vendorId!, printer.productId!);
if (usbDevice == null) {
return Future.error('Usb device is empty');
}
}
}