resizeIfNeeded static method
Composes the provider
in a ResizeImage only when cacheWidth
and
cacheHeight
are not both null.
When cacheWidth
and cacheHeight
are both null, this will return the
provider
directly.
Extended with scaling
and maxBytes
.
Implementation
static ImageProvider<Object> resizeIfNeeded({
required ImageProvider<Object> provider,
int? cacheWidth,
int? cacheHeight,
double? compressionRatio,
int? maxBytes,
bool cacheRawData = false,
String? imageCacheName,
}) {
if ((compressionRatio != null &&
compressionRatio > 0 &&
compressionRatio < 1) ||
(maxBytes != null && maxBytes > 0) ||
cacheWidth != null ||
cacheHeight != null) {
return ExtendedResizeImage(
provider,
width: cacheWidth,
height: cacheHeight,
maxBytes: maxBytes,
compressionRatio: compressionRatio,
cacheRawData: cacheRawData,
imageCacheName: imageCacheName,
);
}
return provider;
}