TimelineAnimation<T> constructor

TimelineAnimation<T>({
  1. PropertyLerp<T>? lerp,
  2. required List<Keyframe<T>> keyframes,
})

Implementation

factory TimelineAnimation({
  PropertyLerp<T>? lerp,
  required List<Keyframe<T>> keyframes,
}) {
  lerp ??= defaultLerp;
  assert(keyframes.isNotEmpty, 'No keyframes found');
  Duration current = Duration.zero;
  for (var i = 0; i < keyframes.length; i++) {
    final keyframe = keyframes[i];
    assert(keyframe.duration.inMilliseconds > 0, 'Invalid duration');
    current += keyframe.duration;
  }
  return TimelineAnimation._(
    lerp: lerp,
    totalDuration: current,
    keyframes: keyframes,
  );
}