diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index c978fa184..7167c941c 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -80,6 +80,10 @@ /> + copyCompressedImageToTarget({ await source.copy(target); } } + +Future cropImage(BuildContext context, File imageFile) async { + final croppedFile = await ImageCropper().cropImage( + sourcePath: imageFile.path, + uiSettings: [ + AndroidUiSettings( + aspectRatioPresets: [ + CropAspectRatioPreset.original, + CropAspectRatioPreset.square, + ], + ), + IOSUiSettings( + aspectRatioPresets: [ + CropAspectRatioPreset.original, + CropAspectRatioPreset.square, + ], + ), + ], + ); + if (croppedFile == null) return null; + return File(croppedFile.path); +} diff --git a/pubspec.lock b/pubspec.lock index daa962ca5..fc0b75975 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1234,6 +1234,30 @@ packages: url: "https://pub.dev" source: hosted version: "4.2.0" + image_cropper: + dependency: "direct main" + description: + name: image_cropper + sha256: fe37d9a129411486e0d93089b61bd326d05b89e78ad4981de54b560725bf5bd5 + url: "https://pub.dev" + source: hosted + version: "8.0.2" + image_cropper_for_web: + dependency: transitive + description: + name: image_cropper_for_web + sha256: "34256c8fb7fcb233251787c876bb37271744459b593a948a2db73caa323034d0" + url: "https://pub.dev" + source: hosted + version: "6.0.2" + image_cropper_platform_interface: + dependency: transitive + description: + name: image_cropper_platform_interface + sha256: e8e9d2ca36360387aee39295ce49029362ae4df3071f23e8e71f2b81e40b7531 + url: "https://pub.dev" + source: hosted + version: "7.0.0" image_picker: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index d40c9102b..4ae9c9f3a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -163,7 +163,7 @@ dependencies: super_context_menu: ^0.8.22 animated_size_and_fade: ^4.0.0 dismissible_page: ^1.0.2 - + image_cropper: ^8.0.2 # Utils # dart.io.Platform API for Web universal_platform: ^1.1.0 diff --git a/web/index.html b/web/index.html index 8ea3013cd..1b657e7fb 100644 --- a/web/index.html +++ b/web/index.html @@ -46,6 +46,9 @@ + + +