pickPhoto function
Implementation
Future<String?> pickPhoto(bool isCam) async {
ImagePicker _picker = ImagePicker();
final permissionList;
if (Platform.isIOS) {
permissionList = [Permission.photos];
} else if (Platform.isAndroid) {
if (await PlatformUtils.isAboveAndroidT()) {
permissionList = [Permission.photos, Permission.videos];
} else {
permissionList = [Permission.storage];
}
} else {
permissionList = [];
}
if (!isCam) {
final granted = await PermissionsHelper.requestPermission(permissionList);
if (!granted) {
return null;
}
} else {
final granted =
await PermissionsHelper.requestPermission([Permission.camera]);
if (!granted) {
return null;
}
}
final XFile? photo = await _picker.pickImage(
source: isCam ? ImageSource.camera : ImageSource.gallery,
imageQuality: 80);
if (photo != null) {
return photo.path;
}
return null;
}