getPermission method
Gets Permission in Android and IOS devices.
Not required for Desktop. Directly saves to Downloads folder.
Implementation
Future<PermissionStatus> getPermission() async {
// Don't need permission for desktop devices
if (!Platform.isIOS && !Platform.isAndroid) {
return _permissionStatus = PermissionStatus.granted;
}
// added sdk specifics since new break change to permissions type. Ref from Permission Handler FAQ :
// https://github.com/Baseflow/flutter-permission-handler/blob/main/permission_handler/README.md
if (Platform.isAndroid) {
final deviceInfo = await DeviceInfoPlugin().androidInfo;
if (deviceInfo.version.sdkInt > 32) {
_permissionStatus = await Permission.photos.request();
} else {
_permissionStatus = await Permission.storage.request();
}
} else {
_permissionStatus = await Permission.storage.request();
}
return _permissionStatus;
}