updateTrim method

void updateTrim(
  1. double min,
  2. double max
)

Update minTrim and maxTrim.

The min param is the minimum position of the trimmed area on the slider The max param is the maximum position of the trimmed area on the slider

Arguments range are 0.0 to 1.0.

Implementation

void updateTrim(double min, double max) {
  assert(min < max,
      'Minimum trim value ($min) cannot be bigger and maximum trim value ($max)');
  // check that the new params does not cause a wrong duration
  final double newDuration = videoDuration.inMicroseconds * (max - min);
  // since [Duration] object does not takes integer we must round the
  // new duration up and down to check if the values are correct or not (#157)
  final Duration newDurationCeil = Duration(microseconds: newDuration.ceil());
  final Duration newDurationFloor =
      Duration(microseconds: newDuration.floor());
  assert(newDurationFloor <= maxDuration,
      'Trim duration ($newDurationFloor) cannot be smaller than $minDuration');
  assert(newDurationCeil >= minDuration,
      'Trim duration ($newDurationCeil) cannot be bigger than $maxDuration');

  _minTrim = min;
  _maxTrim = max;
  _updateTrimRange();
}