getRequiredBluetoothPermissions static method

Future<List<Permission>> getRequiredBluetoothPermissions()

Returns the list of Permissions required for Bluetooth on the current platform/version.

  • Android 10 & 11 (API 29 & 30): Requires Permission.locationWhenInUse (Fine Location) for Bluetooth discovery. Standard Bluetooth permissions are granted at install-time via Manifest.

  • Android 12 to 17+ (API 31+): Requires Permission.bluetoothScan and Permission.bluetoothConnect. Permission.locationWhenInUse is included for fallback / beacon discovery.

  • iOS / other platforms: Requires Permission.bluetooth.

Implementation

static Future<List<Permission>> getRequiredBluetoothPermissions() async {
  if (!_isAndroid) {
    return [Permission.bluetooth];
  }

  final int? sdkInt = await getAndroidSdkVersion();

  if (sdkInt != null && sdkInt < 31) {
    // Android 10 (API 29) & Android 11 (API 30)
    return [
      Permission.locationWhenInUse,
      Permission.bluetooth,
    ];
  }

  // Android 12 to 17+ (API 31 - 37+), or fallback if SDK version detection is unavailable
  return [
    Permission.bluetoothScan,
    Permission.bluetoothConnect,
    Permission.locationWhenInUse,
  ];
}