startScan method

Future startScan({
  1. ScanMode scanMode = ScanMode.lowLatency,
  2. List<Guid> withServices = const [],
  3. List<Guid> withDevices = const [],
  4. Duration? timeout,
  5. bool allowDuplicates = false,
})

Starts a scan and returns a future that will complete once the scan has finished.

Once a scan is started, call stopScan to stop the scan and complete the returned future.

timeout automatically stops the scan after a specified Duration.

To observe the results while the scan is in progress, listen to the scanResults stream, or call scan instead.

Implementation

Future startScan({
  ScanMode scanMode = ScanMode.lowLatency,
  List<Guid> withServices = const [],
  List<Guid> withDevices = const [],
  Duration? timeout,
  bool allowDuplicates = false,
}) async {
  await scan(
          scanMode: scanMode,
          withServices: withServices,
          withDevices: withDevices,
          timeout: timeout,
          allowDuplicates: allowDuplicates)
      .drain();
  return _scanResults.value;
}