Skip to content

Commit

Permalink
add some checks if FlutterBlue is not set up
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Jun 11, 2024
1 parent c6a6206 commit 362787e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Backend/Bluetooth/bluetooth_manager_plus.dart
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ Future<void> initFlutterBluePlus(InitFlutterBluePlusRef ref) async {
}

Future<void> disconnect(String id) async {
if (!_didInitFlutterBluePlus) {
return;
}
BluetoothDevice? device = flutterBluePlus.connectedDevices.firstWhereOrNull((element) => element.remoteId.str == id);
if (device != null) {
_bluetoothPlusLogger.info("disconnecting from ${device.advName}");
Expand All @@ -356,10 +359,16 @@ Future<void> beginScan({Duration? timeout}) async {
}

bool isScanningNow() {
if (!_didInitFlutterBluePlus) {
return false;
}
return flutterBluePlus.isScanningNow;
}

Stream<bool> isScanning() {
if (!_didInitFlutterBluePlus) {
return Stream.value(false);
}
return flutterBluePlus.isScanning;
}

Expand Down

0 comments on commit 362787e

Please sign in to comment.