You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I start the scan with BT disabled then obviously no devices will be found, but the issues is that an Unhandled Exception will be thrown, which isn't graceful:
BluetoothManager bluetoothManager = BluetoothManager.instance;
//...
bluetoothManager.startScan(timeout: Duration(seconds: 2));
[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(startScan, getBluetoothLeScanner() is null. Is the Adapter on?, null)
#0 BluetoothManager.scan (package:flutter_bluetooth_basic/src/bluetooth_manager.dart:85:7)
<asynchronous suspension>
#1 BluetoothManager.startScan (package:flutter_bluetooth_basic/src/bluetooth_manager.dart:116:11)...
I can work around that by catching it, like so:
bluetoothManager.startScan(timeout: Duration(seconds: 2)).catchError((e){
// tell the user to check if BT is on.
// print(e);
});
But that isn't graceful either IMHO, also I don't know if the devices is missing BT (like an emulator) or it is just turned off.
I noticed that in "FlutterBluetoothBasicPlugin.java" these cases are already covered:
case "isAvailable":
result.success(mBluetoothAdapter != null);
break;
case "isOn":
result.success(mBluetoothAdapter.isEnabled());
break;
So it would be nice if we could call them from Flutter with bluetoothManager.isAvailable() and bluetoothManager.isOn().
The text was updated successfully, but these errors were encountered:
If I start the scan with BT disabled then obviously no devices will be found, but the issues is that an Unhandled Exception will be thrown, which isn't graceful:
I can work around that by catching it, like so:
But that isn't graceful either IMHO, also I don't know if the devices is missing BT (like an emulator) or it is just turned off.
I noticed that in "FlutterBluetoothBasicPlugin.java" these cases are already covered:
So it would be nice if we could call them from Flutter with bluetoothManager.isAvailable() and bluetoothManager.isOn().
The text was updated successfully, but these errors were encountered: