update method

  1. @override
void update(
  1. double t
)
override

Sets the motion to a specific point in time. The t value that is passed in is a normalized value 0.0 to 1.0 of the duration of the motion. Every motion will always recieve a callback with the end time point (1.0), unless it is cancelled.

Implementation

@override
void update(double t) {
  if (t >= 1.0) {
    // Finish all unfinished motions
    for (Motion motion in _motions) {
      if (!motion._finished) {
        motion.update(1.0);
        motion._finished = true;
      }
    }
  } else {
    for (Motion motion in _motions) {
      if (motion.duration == 0.0) {
        // Fire all instant motions immediately
        if (!motion._finished) {
          motion.update(1.0);
          motion._finished = true;
        }
      } else {
        // Update child motions
        double ta = (t / (motion.duration / duration)).clamp(0.0, 1.0);
        if (ta < 1.0) {
          if (motion is MotionInterval) {
            MotionInterval motionInterval = motion;
            if (motionInterval.curve == null) {
              motion.update(ta);
            } else {
              motion.update(motionInterval.curve!.transform(ta));
            }
          } else {
            motion.update(ta);
          }
        } else if (!motion._finished) {
          motion.update(1.0);
          motion._finished = true;
        }
      }
    }
  }
}