cropImageDoc static method

Future<File?> cropImageDoc(
  1. String from
)

Implementation

static Future<File?> cropImageDoc(String from) async {

  var pickedImage;
  if(from=="gallery") {
     pickedImage = await ImagePicker().pickImage(
        source: ImageSource.gallery,imageQuality: 50);
  }else if(from=="camera"){
     pickedImage = await ImagePicker().pickImage(
        source: ImageSource.camera,imageQuality: 50);
  }
  if (pickedImage != null) {

    var croppedFile = await ImageCropper().cropImage(
      sourcePath: pickedImage.path,
      aspectRatioPresets: [
        CropAspectRatioPreset.square,
        CropAspectRatioPreset.ratio3x2,
        CropAspectRatioPreset.original,
        CropAspectRatioPreset.ratio4x3,
        CropAspectRatioPreset.ratio16x9
      ],
      androidUiSettings:AndroidUiSettings(
            toolbarTitle: 'Powered by Chromepay',
            toolbarColor: Colors.orange,
            toolbarWidgetColor: Colors.white,
            initAspectRatio: CropAspectRatioPreset.original,
            lockAspectRatio: false),
        iosUiSettings:IOSUiSettings(
          title: 'Powered by Chromepay',),

    );

    if (croppedFile != null) {

      // final watermarkedImageFile = await addWatermarkToFile(
      //   imageFile: croppedFile,
      //   watermarkText: 'Powered by chromepay',
      // );

      return File(croppedFile.path);
    }
  }

  return null;
}