findPrinters static method

Future<List<StarXpandPrinter>> findPrinters({
  1. List<StarXpandInterface> interfaces = const [StarXpandInterface.usb, StarXpandInterface.bluetooth, StarXpandInterface.bluetoothLE, StarXpandInterface.lan],
  2. int timeout = 3000,
  3. StarXpandCallback<StarXpandPrinterPayload>? callback,
})

Implementation

static Future<List<StarXpandPrinter>> findPrinters(
    {List<StarXpandInterface> interfaces = const [
      StarXpandInterface.usb,
      StarXpandInterface.bluetooth,
      StarXpandInterface.bluetoothLE,
      StarXpandInterface.lan
    ],
    int timeout = 3000,
    StarXpandCallback<StarXpandPrinterPayload>? callback}) async {
  var guid = _addCallbackHandler(
      StarXpandCallbackHandler<StarXpandPrinterPayload>(
          (payload) => callback?.call(payload),
          (type, data) => StarXpandPrinterPayload(
              type, Map<String, dynamic>.from(data))));

  Map<String, dynamic> result =
      Map<String, dynamic>.from(await _channel.invokeMethod('findPrinters', {
    "callback": guid,
    "timeout": timeout,
    "interfaces": interfaces.map((e) => e.name).toList()
  }) as Map);

  _removeCallbackHandler(guid);

  List printers = result["printers"];
  return printers
      .map((e) => StarXpandPrinter.fromMap(Map<String, dynamic>.from(e)))
      .toList();
}