Untitled

mail@pastecode.io avatar
unknown
dart
2 years ago
790 B
2
Indexable
Never
  Future<File?> cropImage(File file) async {
    File? newFile;

    CroppedFile? cropped = await ImageCropper().cropImage(
      sourcePath: file.path,
      compressQuality: 10,
      cropStyle: CropStyle.rectangle,
      compressFormat: ImageCompressFormat.jpg,
      aspectRatio: const CropAspectRatio(ratioX: 1, ratioY: 1),
      uiSettings: [
        AndroidUiSettings(
          toolbarColor: Get.theme.primaryColor,
          toolbarTitle: 'Crop Image',
          statusBarColor: AppColors.white,
          backgroundColor: AppColors.white,
          activeControlsWidgetColor: Get.theme.focusColor,
        ),
        IOSUiSettings(
          title: 'Cropper',
        ),
      ],
    );
    if (cropped != null) {
      newFile = File(cropped.path);
    }

    return newFile;
  }