imagePicker method
Implementation
Future imagePicker(BuildContext context) async {
if (await AppPermission.getStoragePermission()) {
if (await AppUtils.isNetConnected()) {
FilePickerResult? result = await FilePicker.platform
.pickFiles(allowMultiple: false, type: FileType.image);
if (result != null) {
if (MediaUtils.checkFileUploadSize(
result.files.single.path!, Constants.mImage)) {
isImageSelected.value = true;
NavUtils.to(CropImage(
imageFile: File(result.files.single.path!),
))?.then((value) {
if (value != null) {
value as MemoryImage;
imageBytes = value.bytes;
var name = "${DateTime.now().millisecondsSinceEpoch}.jpg";
MessageUtils.writeImageTemp(value.bytes, name).then((value) {
if (from == Routes.login) {
imagePath(value.path);
changed(true);
update();
} else {
imagePath(value.path);
// changed(true);
updateProfileImage(value.path, update: false);
}
});
}
});
} else {
toToast(getTranslated("imageLess10mb"));
}
} else {
// User canceled the picker
isImageSelected.value = false;
}
} else {
toToast(getTranslated("noInternetConnection"));
}
}
}