withSize function

ImageProvider<Object> withSize(
  1. ImageProvider<Object> base, {
  2. int? width,
  3. int? height,
})

Implementation

ImageProvider<Object> withSize(
  ImageProvider<Object> base, {
  int? width,
  int? height,
}) {
  if (width == null && height == null) return base;

  // IMPORTANT: never pass both; it can distort aspect ratio across platforms.
  if (width != null && height != null) {
    final side = math.max(width, height);
    return ResizeImage(base, width: side);
  }

  return ResizeImage(base, width: width, height: height);
}