isConnected method
Check if a device is connected
Implementation
Future<bool> isConnected(Printer device) async {
if (_usesSystemQueue(device) ||
device.connectionType == ConnectionType.USB) {
if (Platform.isWindows) {
return _windowsQueueReady(device);
} else {
return FlutterThermalPrinterPlatform.instance.isConnected(device);
}
} else if (device.connectionType == ConnectionType.NETWORK) {
return _networkClients[device.address]?.isConnected ?? false;
} else if (device.connectionType == ConnectionType.BLE) {
try {
if (device.address == null) {
return false;
}
return await _isBleDeviceConnected(device.address!);
} catch (e) {
log('Failed to check connection status: $e');
return false;
}
}
return false;
}