transform method

  1. @override
T transform(
  1. double t
)
override

Returns the value of the object at point t.

The value of t is nominally a fraction in the range 0.0 to 1.0, though in practice it may extend outside this range.

See also:

Implementation

@override
T transform(double t) {
  assert(t >= 0 && t <= 1, 'Invalid time');
  assert(keyframes.isNotEmpty, 'No keyframes found');
  var duration = _computeDuration(t);
  Duration current = Duration.zero;
  for (var i = 0; i < keyframes.length; i++) {
    final keyframe = keyframes[i];
    final start = current;
    final end = current + keyframe.duration;
    if (duration <= end) {
      final relative = (duration - start).inMilliseconds /
          keyframe.duration.inMilliseconds;
      return keyframe.compute(this, i, relative);
    }
  }
  // Should never reach here
  throw AssertionError('Invalid time');
}