mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-27 05:56:39 +10:00
BLE select cancel
This commit is contained in:
@@ -45,17 +45,22 @@ class _ScannerScreenState extends State<ScannerScreen> {
|
||||
|
||||
connector.addListener(_connectionListener);
|
||||
|
||||
_bluetoothStateSubscription = FlutterBluePlus.adapterState.listen((state) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_bluetoothState = state;
|
||||
});
|
||||
// Cancel scan if Bluetooth turns off while scanning
|
||||
if (state != BluetoothAdapterState.on) {
|
||||
unawaited(connector.stopScan());
|
||||
_bluetoothStateSubscription = FlutterBluePlus.adapterState.listen(
|
||||
(state) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_bluetoothState = state;
|
||||
});
|
||||
// Cancel scan if Bluetooth turns off while scanning
|
||||
if (state != BluetoothAdapterState.on) {
|
||||
unawaited(connector.stopScan());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
onError: (Object e) {
|
||||
debugPrint("Scanner adapterState stream error: $e");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -107,7 +112,9 @@ class _ScannerScreenState extends State<ScannerScreen> {
|
||||
if (isScanning) {
|
||||
connector.stopScan();
|
||||
} else {
|
||||
connector.startScan();
|
||||
unawaited(connector.startScan().catchError((e) {
|
||||
debugPrint("Scanner screen startScan error: $e");
|
||||
}));
|
||||
}
|
||||
},
|
||||
icon: isScanning
|
||||
|
||||
Reference in New Issue
Block a user