requestBluetoothPermissions method

Future<bool> requestBluetoothPermissions()

Implementation

Future<bool> requestBluetoothPermissions() async {
  if (Platform.isAndroid) {
    if (await _isAndroid12OrAbove()) {
      var scan = await Permission.bluetoothScan.request();
      var connect = await Permission.bluetoothConnect.request();
      var location = await Permission.locationWhenInUse.request(); // Some devices still need it
      return scan.isGranted && connect.isGranted && location.isGranted;
    } else {
      var location = await Permission.locationWhenInUse.request();
      return location.isGranted;
    }
  }
  return true; // Non-Android
}