getDefaultOffsets method
Returns the default start and end offsets for cropping. The offsets are based on computing the maximum length that can surround the middle of the video.
Implementation
(Duration start, Duration end) getDefaultOffsets(final Duration duration) {
final int middleMilliseconds =
(duration.inMilliseconds.toDouble() / 2).round();
final int startMilliseconds =
max(middleMilliseconds - (maxLength.inMilliseconds ~/ 2), 0);
final int endMilliseconds = min(
middleMilliseconds + (maxLength.inMilliseconds ~/ 2),
duration.inMilliseconds,
);
return (
Duration(milliseconds: startMilliseconds),
Duration(milliseconds: endMilliseconds)
);
}