mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-28 22:38:43 +10:00
linted and added greying out
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user