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) {
      // Get.to(CropImage(
      //   imageFile: File(result.files.single.path!),
      // ))?.then((value) {
      if (context.mounted) {
        Navigator.push(
            context,
            MaterialPageRoute(
                builder: (con) => CropImage(
                      imageFile: File(result.files.single.path!),
                    ))).then((value) {
          value as MemoryImage;
          var name = "${DateTime.now().millisecondsSinceEpoch}.jpg";
          writeImageTemp(value.bytes, name).then((value) {
            imagePath(value.path);
            updateGroupProfileImage(value.path, context);
          });
        });
      }
    } else {
      // User canceled the picker
    }
  } else {
    toToast(AppConstants.noInternetConnection);
  }
}