scan method

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

Scan for Bluetooth LE devices until timeout is reached. scanFilters filters the scan results. Throw BTException if failed.

Implementation

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