enableBluetooth method

Future<bool> enableBluetooth()

Implementation

Future<bool> enableBluetooth() async {
  BluetoothState? state = await FlutterBluetoothSerial.instance.state;
  if (state == BluetoothState.STATE_OFF) {
    try {
      await FlutterBluetoothSerial.instance.requestEnable();
      return true;
    } catch (e) {
      print('Failed to enable Bluetooth: $e');
      return false;
    }
  }
  return true;
}