updateClipTrim method
Sets the clip's in/out points in file time. Image clips have no source length, so for them the range only sets the display duration.
Implementation
void updateClipTrim(int index, Duration start, Duration end) {
if (index < 0 || index >= _clips.length) return;
final clip = _clips[index];
if (clip.isImage) {
final length = end - start;
final duration = length < const Duration(milliseconds: 100)
? const Duration(milliseconds: 100)
: length;
_clips[index] = clip.copyWith(
duration: duration,
startTime: Duration.zero,
endTime: duration,
clearConvertedVideoFile: true,
);
} else {
final max = clip.duration > Duration.zero ? clip.duration : end;
var s = start < Duration.zero ? Duration.zero : start;
var e = end > max ? max : end;
if (e - s < const Duration(milliseconds: 100)) {
e = s + const Duration(milliseconds: 100);
if (e > max) {
e = max;
s = e - const Duration(milliseconds: 100);
if (s < Duration.zero) s = Duration.zero;
}
}
_clips[index] = clip.copyWith(
startTime: s,
endTime: e,
);
}
_clips[index].markEdited();
}