addScene method

TimelineScene<T> addScene({
  1. Duration? begin,
  2. Duration? duration,
  3. Duration? end,
  4. Curve? curve,
})

Adds a new scene to the timeline. A scene is specified with a time span. The time span can be set by providing either

  • begin and end
  • begin and duration
  • duration and end.

By default the scene uses a linear easing curve for all it's animated properties. This can be change by specifying a curve.

Implementation

TimelineScene<T> addScene({
  Duration? begin,
  Duration? duration,
  Duration? end,
  Curve? curve,
}) {
  assert(
      (begin != null && duration != null && end == null) ||
          (begin != null && duration == null && end != null) ||
          (begin == null && duration != null && end != null),
      'When using addScene() specify exactly two of these properties: begin, duration, end');

  if (begin != null && end != null) {
    duration = end - begin;
  }

  if (end != null && duration != null) {
    begin = end - duration;
  }

  assert(duration! >= Duration.zero,
      'Scene duration must be or result in a positive value');
  assert(begin! >= Duration.zero,
      'Scene begin must be or result in a positive value');

  var scene = TimelineScene<T>(
    begin: begin!,
    duration: duration!,
    curve: curve,
    parent: this,
  );
  _scenes.add(scene);
  return scene;
}