cropImageDoc static method

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

Implementation

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

  var pickedImage;
  if(from=="gallary") {
     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,
      uiSettings: [
        AndroidUiSettings(
            toolbarTitle: 'Authentication powered by Chromepay',
            toolbarColor: Colors.orange,
            toolbarWidgetColor: Colors.white,
            initAspectRatio: CropAspectRatioPreset.original,
            lockAspectRatio: false,
          aspectRatioPresets: [
            CropAspectRatioPreset.square,
            CropAspectRatioPreset.ratio3x2,
            CropAspectRatioPreset.original,
            CropAspectRatioPreset.ratio4x3,
            CropAspectRatioPreset.ratio16x9
          ],
        ),
        IOSUiSettings(
          title: 'Authentication powered by Chromepay',
          aspectRatioPresets: [
            CropAspectRatioPreset.square,
            CropAspectRatioPreset.ratio3x2,
            CropAspectRatioPreset.original,
            CropAspectRatioPreset.ratio4x3,
            CropAspectRatioPreset.ratio16x9
          ],
        ),
      ],
    );

    if (croppedFile != null) {

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

      return File(croppedFile.path);
    }
  }

  return null;
}