dart - Bluetooth package for Bluetooth classic devices in flutter - Stack Overflow

admin2025-04-15  0

I have Bluetooth classic device and I have used bluetooth_classic package and succeeded on getting the device in scan.

but I am not able to stop the subscription which I started during scanning process.

and getting this error when I stop the scan and then again starting the scan second time: Stream has already been listened to.

late StreamSubscription<Device> _scanResultsSubscription;

_scanResultsSubscription = _bluetoothClassicPlugin.onDeviceDiscovered().listen(
  (event) {
    _discoveredDevices = [..._discoveredDevices, event];
  },
);
   @override
  void dispose() {
    _scanResultsSubscription.cancel();
    super.dispose();
  }

转载请注明原文地址:http://www.anycun.com/QandA/1744715509a86621.html