checkAndRequestPermissions method
Checks and requests the Bluetooth permissions needed to scan and connect.
On Android 12+ (API 31+) requests:
Permission.bluetoothScanPermission.bluetoothConnect
On Android < 12 requests:
Permission.bluetoothPermission.locationWhenInUse(required by the OS to discover nearby devices)
On iOS requests: Checks and requests the required Bluetooth permissions according to the running OS version (supports Android 10 to Android 17+).
Returns true when every required permission is granted, false otherwise.
If any permission is permanently denied and openSettingsIfDenied is true,
opens the app settings so the user can enable it manually.
Implementation
Future<bool> checkAndRequestPermissions({bool openSettingsIfDenied = true}) async {
return BluetoothPermissionHelper.checkAndRequestPermissions(
openSettingsIfPermanentlyDenied: openSettingsIfDenied,
);
}