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(videoDimension, 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();
  }
}