getPrinters method
getPrinters() returns a Map of Strings representing the printer name and how it was discovered via the discovery scan. Items from this list will only be removed on subsequent launches of the app.
Implementation
@override
Future<Map<String, String>> getPrinters() async {
String? printerNames =
await methodChannel.invokeMethod<String>('getPrinters');
List<String> printerNamesList = printerNames!.split(', ');
printerNamesList.removeLast();
String? printerProtocols =
await methodChannel.invokeMethod<String>('getPrinterProtocols');
List<String> printerProtocolsList = printerProtocols!.split(', ');
printerProtocolsList.removeLast();
Map<String, String> printerList = {};
for (var i = 0; i < printerNamesList.length; i++) {
printerList[printerNamesList[i]] = printerProtocolsList[i];
}
return printerList;
}