getPrinters method
void
getPrinters({
- Duration refreshDuration = const Duration(seconds: 5),
- List<
ConnectionType> connectionTypes = const [ConnectionType.BLE, ConnectionType.USB],
Implementation
void getPrinters({
Duration refreshDuration = const Duration(seconds: 5),
List<ConnectionType> connectionTypes = const [
ConnectionType.BLE,
ConnectionType.USB,
],
}) async {
List<Printer> btlist = [];
if (connectionTypes.contains(ConnectionType.BLE)) {}
List<Printer> list = [];
if (connectionTypes.contains(ConnectionType.USB)) {
_usbSubscription?.cancel();
_usbSubscription =
Stream.periodic(refreshDuration, (x) => x).listen((event) async {
final devices = PrinterNames(PRINTER_ENUM_LOCAL);
List<Printer> templist = [];
for (var e in devices.all()) {
final device = Printer(
vendorId: e,
productId: "N/A",
name: e,
connectionType: ConnectionType.USB,
address: e,
isConnected: true,
);
templist.add(device);
}
list = templist;
});
}
Stream.periodic(refreshDuration, (x) => x).listen((event) {
_devicesstream.add(list + btlist);
});
}