scan method

  1. @override
Future<List<BluetoothDevice>> scan({
  1. required Duration timeout,
})
override

Scan for Bluetooth LE devices until timeout is reached. Throw BTException if failed.

Implementation

@override
Future<List<BluetoothDevice>> scan({required Duration timeout}) async {
  try {
    Future.delayed(timeout).whenComplete(() => _stopScanPill.add(null));
    await discovery().drain();
    return _scanResults.value;
  } on BTException catch (_) {
    rethrow;
  } on PlatformException catch (e) {
    throw BTException.fromPlatform(e);
  }
}