Closed azimuthdeveloper closed 2 years ago
There is isBluetoothAvailable
. Why check the bluetoothRadio
again in startScan
?
Because if there isn't an available BLE adapter or its turned off on the system, it causes a native crash, which makes the entire app crash. I'm trying to prevent against native crashes for any reason.
Fix async & format
On Windows, if
startScan()
is called while the Bluetooth switch is in the "off" state, quick_blue causes a native crash.This PR first checks that Bluetooth is enabled, and if it is not, returns an error back up to the Flutter system to deal with.
It also changes the implementation of
startScan
toasync
. That's because, in my tests, it seems like the error was only caught properly ifstartScan
was made async.EDIT: Also check if the bluetooth adapter is available before trying to use it. It's possible that the bluetooth object could be null if there was no eligible hardware to be used on the computer.