image_crop icon indicating copy to clipboard operation
image_crop copied to clipboard

How can I use 16:9 type aspectRatio?

Open NTMS2017 opened this issue 6 years ago • 1 comments

How can I use 16:9 type aspectRatio? I need the crop area be fixed and I need to move only image. I need rectangle type crop area to certain width and height. How can I do that?

child: Crop.file( _sample, key: cropKey, alwaysShowGrid: true, aspectRatio: 4.0 / 3.0,),

NTMS2017 avatar Jun 01 '19 08:06 NTMS2017

@NTMS2017 If I understand you correctly, then it’s quite simple

final media = MediaQuery.of(context);
final height = (media.size.width / 16) * 9;

SizedBox(
  width: media.size.width,
  height: height,
  child: Crop.file(
    image,
    key: _cropKey,
    aspectRatio: 16 / 9,
  ),
);

SergeShkurko avatar Jan 25 '20 11:01 SergeShkurko