getDeviceList method

  1. @override
Future<List<UsbDevice>> getDeviceList()
inherited

Implementation

@override
Future<List<UsbDevice>> getDeviceList() {
  var deviceListPtr = ffi.calloc<Pointer<Pointer<libusb_device>>>();
  try {
    var count = _libusb.libusb_get_device_list(nullptr, deviceListPtr);
    if (count < 0) {
      return Future.value([]);
    }
    try {
      return Future.value(_iterateDevice(deviceListPtr.value).toList());
    } finally {
      _libusb.libusb_free_device_list(deviceListPtr.value, 1);
    }
  } finally {
    ffi.calloc.free(deviceListPtr);
  }
}