import 'dart:ui';

class MyImageHolder {
  MyImageHolder(this.image);

  final Image image;

  void draw(Canvas canvas, Size size) {
    final double scale = size.width / image.width;
    final double offsetY = (size.height - image.height * scale) / 2;
    canvas.drawImageRect(
        image,
        Rect.fromLTWH(0, 0, image.width.toDouble(), image.height.toDouble()),
        Rect.fromLTWH(0, offsetY, size.width, image.height * scale),
        Paint());
  }

  void dispose() => image.dispose();
}
