ImageDrawable.fittedToSize constructor

ImageDrawable.fittedToSize({
  1. required Offset position,
  2. required Size size,
  3. double rotationAngle = 0,
  4. Set<ObjectDrawableAssist> assists = const <ObjectDrawableAssist>{},
  5. Map<ObjectDrawableAssist, Paint> assistPaints = const <ObjectDrawableAssist, Paint>{},
  6. bool locked = false,
  7. bool hidden = false,
  8. required Image image,
  9. bool flipped = false,
})

Creates an ImageDrawable with the given image, and calculates the scale based on the given size. The scale will be calculated such that the size of the drawable fits into the provided size.

For example, if the image was 512x256 and the provided size was 128x128, the scale would be 0.25, fitting the width of the image into the size (128x64).

Implementation

ImageDrawable.fittedToSize({
  required Offset position,
  required Size size,
  double rotationAngle = 0,
  Set<ObjectDrawableAssist> assists = const <ObjectDrawableAssist>{},
  Map<ObjectDrawableAssist, Paint> assistPaints =
      const <ObjectDrawableAssist, Paint>{},
  bool locked = false,
  bool hidden = false,
  required Image image,
  bool flipped = false,
}) : this(
          position: position,
          rotationAngle: rotationAngle,
          scale: _calculateScaleFittedToSize(image, size),
          assists: assists,
          assistPaints: assistPaints,
          image: image,
          flipped: flipped,
          hidden: hidden,
          locked: locked);