requestPermissions method
Request the necessary permissions on Android
Implementation
Future<void> requestPermissions() async {
if (Platform.isAndroid) {
final androidDeviceInfo = await DeviceInfoPlugin().androidInfo;
final sdkInt = androidDeviceInfo.version.sdkInt;
// If we are on Android M+
if (sdkInt >= 23) {
// If we are on an Android version before S or bluetooth scan is used to derive location
if (sdkInt < 31 || !_bluetoothScanNeverForLocation) {
await Permission.location.request();
}
// If we are on Android S+
if (sdkInt >= 31) {
await Permission.bluetoothScan.request();
await Permission.bluetoothConnect.request();
}
}
}
}