diff --git a/CHANGELOG.md b/CHANGELOG.md index d6036e99..1bfc7da4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +## 4.0.0-non-null-safety + +* Breaking change: + + 1. we cache raw image pixels as default behavior at previous versions, it's not good for heap memory usage. so add [ExtendedImageProvider.cacheRawData] to support whether should cache the raw image pixels. It's [false] now. + +* Improve: + + 1. add [ExtendedResizeImage] to support resize image more convenient. + 2. add [ExtendedImageProvider.imageCacheName] to support custom ImageCache to store ExtendedImageProvider. + 3. add MemoryUsageDemo. #315 + +* Issues: + 1. fix issue that [EditorConfig.editActionDetailsIsChanged] is not fire when change crop area. #317 ## 3.0.0-non-null-safety * non-null-safety @@ -5,7 +19,6 @@ Remove [TransparentMaterialPageRoute] and [TransparentMaterialPageRoute] * Improve: Add [ExtendedNetworkImageProvider.printError] - ## 2.0.0 * Improve: diff --git a/lib/src/extended_image.dart b/lib/src/extended_image.dart index 8836258a..7ca89273 100644 --- a/lib/src/extended_image.dart +++ b/lib/src/extended_image.dart @@ -114,13 +114,15 @@ class ExtendedImage extends StatefulWidget { this.isAntiAlias = false, String cacheKey, bool printError = true, - }) : assert(cacheWidth == null || cacheWidth > 0), + double compressionRatio, + int maxBytes, + bool cacheRawData = false, + String imageCacheName, + }) : assert(url != null), + assert(cacheWidth == null || cacheWidth > 0), assert(cacheHeight == null || cacheHeight > 0), - assert(isAntiAlias != null), - image = ResizeImage.resizeIfNeeded( - cacheWidth, - cacheHeight, - ExtendedNetworkImageProvider( + image = ExtendedResizeImage.resizeIfNeeded( + provider: ExtendedNetworkImageProvider( url, scale: scale, headers: headers, @@ -131,7 +133,15 @@ class ExtendedImage extends StatefulWidget { timeLimit: timeLimit, cacheKey: cacheKey, printError: printError, + cacheRawData: cacheRawData, + imageCacheName: imageCacheName, ), + compressionRatio: compressionRatio, + maxBytes: maxBytes, + cacheWidth: cacheWidth, + cacheHeight: cacheHeight, + cacheRawData: cacheRawData, + imageCacheName: imageCacheName, ), assert(constraints == null || constraints.debugAssertIsValid()), constraints = (width != null || height != null) @@ -154,7 +164,7 @@ class ExtendedImage extends StatefulWidget { /// On Android, this may require the /// `android.permission.READ_EXTERNAL_STORAGE` permission. /// - /// Use [filterQuality] to change the quality when scaling an image. + /// Use [filterQuality] to change the quality when scailing an image. /// Use the [FilterQuality.low] quality setting to scale the image, /// which corresponds to bilinear interpolation, rather than the default /// [FilterQuality.none] which corresponds to nearest-neighbor. @@ -200,21 +210,27 @@ class ExtendedImage extends StatefulWidget { int cacheWidth, int cacheHeight, this.isAntiAlias = false, - }) : assert(cacheWidth == null || cacheWidth > 0), + double compressionRatio, + int maxBytes, + bool cacheRawData = false, + String imageCacheName, + }) : assert(file != null), + assert(cacheWidth == null || cacheWidth > 0), assert(cacheHeight == null || cacheHeight > 0), - assert(isAntiAlias != null), - image = ResizeImage.resizeIfNeeded( - cacheWidth, - cacheHeight, - ExtendedFileImageProvider( + image = ExtendedResizeImage.resizeIfNeeded( + provider: ExtendedFileImageProvider( file, scale: scale, + cacheRawData: cacheRawData, + imageCacheName: imageCacheName, ), + compressionRatio: compressionRatio, + maxBytes: maxBytes, + cacheWidth: cacheWidth, + cacheHeight: cacheHeight, + cacheRawData: cacheRawData, + imageCacheName: imageCacheName, ), - assert(alignment != null), - assert(repeat != null), - assert(filterQuality != null), - assert(matchTextDirection != null), constraints = (width != null || height != null) ? constraints?.tighten(width: width, height: height) ?? BoxConstraints.tightFor(width: width, height: height) @@ -389,20 +405,37 @@ class ExtendedImage extends StatefulWidget { int cacheWidth, int cacheHeight, this.isAntiAlias = false, - }) : assert(cacheWidth == null || cacheWidth > 0), + double compressionRatio, + int maxBytes, + bool cacheRawData = false, + String imageCacheName, + }) : assert(name != null), + assert(cacheWidth == null || cacheWidth > 0), assert(cacheHeight == null || cacheHeight > 0), - assert(isAntiAlias != null), - image = ResizeImage.resizeIfNeeded( - cacheWidth, - cacheHeight, - scale != null - ? ExtendedExactAssetImageProvider(name, - bundle: bundle, scale: scale, package: package) - : ExtendedAssetImageProvider(name, - bundle: bundle, package: package)), - assert(alignment != null), - assert(repeat != null), - assert(matchTextDirection != null), + image = ExtendedResizeImage.resizeIfNeeded( + provider: scale != null + ? ExtendedExactAssetImageProvider( + name, + bundle: bundle, + scale: scale, + package: package, + cacheRawData: cacheRawData, + imageCacheName: imageCacheName, + ) + : ExtendedAssetImageProvider( + name, + bundle: bundle, + package: package, + cacheRawData: cacheRawData, + imageCacheName: imageCacheName, + ), + compressionRatio: compressionRatio, + maxBytes: maxBytes, + cacheWidth: cacheWidth, + cacheHeight: cacheHeight, + cacheRawData: cacheRawData, + imageCacheName: imageCacheName, + ), constraints = (width != null || height != null) ? constraints?.tighten(width: width, height: height) ?? BoxConstraints.tightFor(width: width, height: height) @@ -465,20 +498,27 @@ class ExtendedImage extends StatefulWidget { int cacheWidth, int cacheHeight, this.isAntiAlias = false, - }) : assert(cacheWidth == null || cacheWidth > 0), + double compressionRatio, + int maxBytes, + bool cacheRawData = false, + String imageCacheName, + }) : assert(bytes != null), + assert(cacheWidth == null || cacheWidth > 0), assert(cacheHeight == null || cacheHeight > 0), - assert(isAntiAlias != null), - image = ResizeImage.resizeIfNeeded( - cacheWidth, - cacheHeight, - ExtendedMemoryImageProvider( + image = ExtendedResizeImage.resizeIfNeeded( + provider: ExtendedMemoryImageProvider( bytes, scale: scale, + cacheRawData: cacheRawData, + imageCacheName: imageCacheName, ), + compressionRatio: compressionRatio, + maxBytes: maxBytes, + cacheWidth: cacheWidth, + cacheHeight: cacheHeight, + cacheRawData: cacheRawData, + imageCacheName: imageCacheName, ), - assert(alignment != null), - assert(repeat != null), - assert(matchTextDirection != null), constraints = (width != null || height != null) ? constraints?.tighten(width: width, height: height) ?? BoxConstraints.tightFor(width: width, height: height) diff --git a/pubspec.yaml b/pubspec.yaml index 61b31c11..36e10e09 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,14 +1,14 @@ name: extended_image description: Official extension image, support placeholder(loading)/ failed state, cache network, zoom/pan, photo view, slide out page, editor(crop,rotate,flip), painting etc. -version: 3.0.0-non-null-safety +version: 4.0.0-non-null-safety homepage: https://github.com/fluttercandies/extended_image environment: sdk: ">=2.6.0 <2.12.0" - + flutter: '>1.17.0 <=1.22.6' dependencies: flutter: sdk: flutter - extended_image_library: ^2.0.1-non-null-safety + extended_image_library: ^3.0.0-non-null-safety meta: ^1.1.8