getDevices static method

Future<List<WebBluetoothDevice>> getDevices()

Get a list back of already paired devices. A device becomes paired once a user clicks on it in the pair menu and the web app also connects to the device. If only a user pairs a device, but not connection attempt is made then it won't be marked as paired.

No browser currently supports this without needing a browser flag. https://caniuse.com/mdn-api_bluetooth_getdevices

Will return an empty list if hasGetDevices returns false. See hasGetDevices.

Devices can be removed from this list by calling WebBluetoothDevice.forget on the device.

Implementation

static Future<List<WebBluetoothDevice>> getDevices() async {
  if (!hasGetDevices()) {
    return [];
  }
  return (await _nativeBluetooth.getDevices().toDart).toDart;
}