resizeIfNeeded static method

ImageProvider<Object> resizeIfNeeded(
  1. int? cacheWidth,
  2. int? cacheHeight,
  3. ImageProvider<Object> provider, {
  4. bool useLogicalSize = false,
})

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. If useLogicalSize is true, the cache dimensions are interpreted as logical pixels instead of physical pixels.

Implementation

static ImageProvider<Object> resizeIfNeeded(
  int? cacheWidth,
  int? cacheHeight,
  ImageProvider<Object> provider, {
  bool useLogicalSize = false,
}) {
  if (cacheWidth != null || cacheHeight != null) {
    return ResizeImage(
      provider,
      width: cacheWidth,
      height: cacheHeight,
      useLogicalSize: useLogicalSize,
    );
  }
  return provider;
}