cropAspectRatio method

void cropAspectRatio(
  1. double? value
)

Update the preferredCropAspectRatio param and init/reset crop parameters minCrop & maxCrop to match the desired ratio The crop area will be at the center of the layout

Implementation

void cropAspectRatio(double? value) {
  preferredCropAspectRatio = value;

  if (value != null) {
    final newSize =
        computeSizeWithRatio(Size(_videoWidth, _videoHeight), value);

    Rect centerCrop = Rect.fromCenter(
      center: Offset(_videoWidth / 2, _videoHeight / 2),
      width: newSize.width,
      height: newSize.height,
    );

    minCrop =
        Offset(centerCrop.left / _videoWidth, centerCrop.top / _videoHeight);
    maxCrop = Offset(
        centerCrop.right / _videoWidth, centerCrop.bottom / _videoHeight);
    notifyListeners();
  }
}