imagePicker method

Future imagePicker(
  1. BuildContext context
)

Implementation

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