getPairedDevices static method

Future<List<BluetoothDevice>> getPairedDevices()

Implementation

static Future<List<BluetoothDevice>> getPairedDevices() async {
  try {
    if (kIsWeb) {
      throw PlatformException(
        code: 'WEB_LIMITATION',
        message: 'Paired devices not accessible on web',
        details:
            'Web browsers do not provide access to paired Bluetooth devices',
      );
    }

    final devices = await _platform.getPairedDevices();
    return devices.map((device) => BluetoothDevice.fromMap(device)).toList();
  } catch (e) {
    if (kDebugMode) print('Error getting paired devices: $e');
    rethrow;
  }
}