scan method
Future<List<BluetoothDevice> >
scan({
- required Duration timeout,
- 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);
}
}