roundProgress method
Returns a "rounded" progress value according to the frameRate
Implementation
double roundProgress(double progress, {required FrameRate frameRate}) {
num? fps;
if (frameRate == FrameRate.max) {
return progress;
} else if (frameRate == FrameRate.composition) {
fps = this.frameRate;
}
fps ??= frameRate.framesPerSecond;
var totalFrameCount = seconds * fps;
var frameIndex = (totalFrameCount * progress).toInt();
var roundedProgress = frameIndex / totalFrameCount;
assert(roundedProgress >= 0 && roundedProgress <= 1,
'Progress is $roundedProgress');
return roundedProgress;
}