Skip to content

Commit

Permalink
update to 2.0.0-dev.5
Browse files Browse the repository at this point in the history
  • Loading branch information
chooyan-eng committed Dec 11, 2024
1 parent f6bfd7b commit c824703
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [2.0.0-dev.5] - 2024.12.11
* **Important Breaking Change:** Change the type of `onCropped` callback from `Uint8List` to `CropResult`.
* Add `filterQuality` argument to `Crop` widget.

## [2.0.0-dev.4] - 2024.12.10
* Add `onImageMoved` callback that notifies image moved when `interactive` is enabled.
* Add `overlayBuilder` argument to `Crop` widget that enables to configure overlay on cropping area.
Expand Down
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ Widget build(BuildContext context) {
return Crop(
image: _imageData,
controller: _controller,
onCropped: (image) {
// do something with cropped image data
onCropped: (result) {
switch(result) {
case CropResult.success(:final croppedImage):
// do something with cropped image data
case CropResult.error(:final error):
// do something with error
}
}
);
}
Expand Down Expand Up @@ -105,8 +110,13 @@ Widget build(BuildContext context) {
return Crop(
image: _imageData,
controller: _controller,
onCropped: (image) {
// do something with image data
onCropped: (result) {
switch(result) {
case CropResult.success(:final croppedImage):
// do something with cropped image data
case CropResult.error(:final error):
// do something with error
}
},
aspectRatio: 4 / 3,
Expand Down Expand Up @@ -162,7 +172,7 @@ Widget build(BuildContext context) {
|argument|type|description|
|-|-|-|
|image|Uint8List|Original image data to be cropped. The result of cropping operation can be obtained via `onCropped` callback.|
|onCropped|void Function(Uint8List)|Callback called when cropping operation is completed.|
|onCropped|void Function(CropResult)|Callback called when cropping operation is completed. The result is exposed as `CropResult` object. `CropResult.success()` contains cropped image data, and `CropResult.error()` contains error object.|
|controller|CropController|Controller for managing cropping operation.|
|aspectRatio|double?| Initial aspect ratio of crop rect. Set `null` or just omit if you want to crop images with any aspect ratio. `aspectRatio` can be changed dynamically via setter of `CropController.aspectRatio`. (see below)|
|initialSize|double?| is the initial size of crop rect. `1.0` (or `null`, by default) fits the size of image, which means crop rect extends as much as possible. `0.5` would be the half. This value is also referred when `aspectRatio` changes via `CropController.aspectRatio`.|
Expand All @@ -182,6 +192,7 @@ Widget build(BuildContext context) {
|interactive|bool?|Flag to enable _interactive_ mode that users can move / zoom images. `false` by default|
|fixCropRect|bool?|Flag if crop rect should be fixed on _interactive_ mode. `false` by default|
|clipBehavior|Clip?|Decide clipping strategy for `Crop`. `Clip.hardEdge` by default|
|filterQuality|FilterQuality?|Decide filter quality for `Image` showing target image. `FilterQuality.low` by default|

### for Web

Expand Down
14 changes: 9 additions & 5 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,20 @@ class _CropSampleState extends State<CropSample> {
image: _imageDataList[_currentImage],
onCropped: (result) {
switch (result) {
case CropSuccess():
_croppedData = result.croppedImage;
case CropFailure():
case CropSuccess(:final croppedImage):
_croppedData = croppedImage;
case CropFailure(:final error):
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('Error'),
content: Text('Failed to crop image: ${result.error}'),
content:
Text('Failed to crop image: ${error}'),
actions: [
TextButton(onPressed: () => Navigator.pop(context), child: Text('OK')),
TextButton(
onPressed: () =>
Navigator.pop(context),
child: Text('OK')),
],
),
);
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.0.0-dev.3"
version: "2.0.0-dev.5"
crypto:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: crop_your_image
description: crop_your_image helps your app to embed Widgets for cropping images.
version: 2.0.0-dev.4
version: 2.0.0-dev.5
homepage: https://github.com/chooyan-eng/crop_your_image
topics:
- crop
Expand Down

0 comments on commit c824703

Please sign in to comment.