stopScan method

Future<void> stopScan({
  1. bool stopBle = true,
  2. bool stopUsb = true,
})

Optimized stop scanning with better resource cleanup

Implementation

Future<void> stopScan({
  bool stopBle = true,
  bool stopUsb = true,
}) async {
  try {
    if (stopBle) {
      await _bleSubscription?.cancel();
      _bleSubscription = null;
      await UniversalBle.stopScan();
    }
    if (stopUsb) {
      await _usbSubscription?.cancel();
      _usbSubscription = null;
    }
  } catch (e) {
    log('Failed to stop scanning for devices: $e');
  }
}