linted and added greying out

This commit is contained in:
Leah
2026-02-11 22:58:15 +01:00
parent 9ce00556ec
commit 9332d8126f
+21 -9
View File
@@ -44,12 +44,16 @@ class _ScannerScreenState extends State<ScannerScreen> {
connector.addListener(_connectionListener); connector.addListener(_connectionListener);
_bluetoothStateSubscription = _bluetoothStateSubscription = FlutterBluePlus.adapterState.listen((state) {
FlutterBluePlus.adapterState.listen((state) {
if (mounted) { if (mounted) {
setState(() { setState(() {
_bluetoothState = state; _bluetoothState = state;
}); });
// Cancel scan if Bluetooth turns off while scanning
if (state != BluetoothAdapterState.on &&
connector.state == MeshCoreConnectionState.scanning) {
connector.stopScan();
}
} }
}); });
} }
@@ -94,15 +98,23 @@ class _ScannerScreenState extends State<ScannerScreen> {
builder: (context, connector, child) { builder: (context, connector, child) {
final isScanning = final isScanning =
connector.state == MeshCoreConnectionState.scanning; connector.state == MeshCoreConnectionState.scanning;
final isBluetoothOn = _bluetoothState == BluetoothAdapterState.on;
return FloatingActionButton.extended( return FloatingActionButton.extended(
onPressed: () { onPressed: isBluetoothOn
if (isScanning) { ? () {
connector.stopScan(); if (isScanning) {
} else { connector.stopScan();
connector.startScan(); } else {
} connector.startScan();
}, }
}
: null,
backgroundColor: isBluetoothOn ? null : Colors.grey,
foregroundColor: isBluetoothOn ? null : Colors.white,
mouseCursor: isBluetoothOn
? SystemMouseCursors.click
: SystemMouseCursors.forbidden,
icon: isScanning icon: isScanning
? const SizedBox( ? const SizedBox(
width: 20, width: 20,