startDiscovery static method

Future<List<BluetoothDevice>> startDiscovery()

Implementation

static Future<List<BluetoothDevice>> startDiscovery() async {
  try {
    if (kIsWeb) {
      throw PlatformException(
        code: 'WEB_LIMITATION',
        message: 'Device discovery not supported on web',
        details:
            'Web browsers only support Bluetooth Low Energy (BLE) with user interaction',
      );
    }

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