scanNetworkPrinters static method
Scan for available network printers (Wi-Fi or Ethernet).
Searches for printers on the local network using discovery protocols. Requires appropriate network permissions to be granted.
Returns a list of discovered network printer devices.
Implementation
static Future<List<PrinterDevice>> scanNetworkPrinters() async {
try {
final List<dynamic>? result =
await _channel.invokeMethod<List<dynamic>>('scanNetworkPrinters');
if (result == null) {
return [];
}
return result
.map((device) => PrinterDevice(
name: device['name'] ?? 'Network Printer',
address: device['address'] ?? '',
connectionType: ConnectionType
.ethernet, // Default to Ethernet, can be adjusted if needed
))
.toList();
} catch (e) {
print('Error scanning for network printers: $e');
return [];
}
}