From f554aa88e24fddc02429885021c721c8d7ca9509 Mon Sep 17 00:00:00 2001 From: Codel1417 <13484789+Codel1417@users.noreply.github.com> Date: Thu, 16 May 2024 16:57:17 -0400 Subject: [PATCH] set streamSubscriptions to null on --- lib/Backend/Bluetooth/bluetooth_manager_plus.dart | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/Backend/Bluetooth/bluetooth_manager_plus.dart b/lib/Backend/Bluetooth/bluetooth_manager_plus.dart index ee85e178..b544e56f 100644 --- a/lib/Backend/Bluetooth/bluetooth_manager_plus.dart +++ b/lib/Backend/Bluetooth/bluetooth_manager_plus.dart @@ -256,14 +256,23 @@ Future initFlutterBluePlus(InitFlutterBluePlusRef ref) async { } //cancel streams await _keepAliveStreamSubscription?.cancel(); + _keepAliveStreamSubscription = null; await _onCharacteristicReceivedStreamSubscription?.cancel(); + _onCharacteristicReceivedStreamSubscription = null; await _onConnectionStateChangedStreamSubscription?.cancel(); + _onConnectionStateChangedStreamSubscription = null; await _onDiscoveredServicesStreamSubscription?.cancel(); + _onDiscoveredServicesStreamSubscription = null; await _onMtuChanged?.cancel(); + _onMtuChanged = null; await _adapterStateStreamSubscription?.cancel(); + _adapterStateStreamSubscription = null; await _onScanResultsStreamSubscription?.cancel(); + _onScanResultsStreamSubscription = null; await _onServicesResetStreamSubscription?.cancel(); + _onServicesResetStreamSubscription = null; await _onReadRssiStreamSubscription?.cancel(); + _onReadRssiStreamSubscription = null; // Mark all gear disconnected; ref.read(knownDevicesProvider).forEach( (key, value) => value.deviceConnectionState.value = ConnectivityState.disconnected,