scene method

MovieScene scene({
  1. Duration? begin,
  2. Duration? duration,
  3. Duration? end,
  4. Curve? curve,
})

Adds a new scene to the movie. 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.
  • only duration assuming begin is Duration.zero.

Implementation

MovieScene scene({
  /// Time in duration at which the scene starts.
  Duration? begin,

  /// Duration of the scene.
  Duration? duration,

  /// Time in duration at which the scene ends.
  Duration? end,

  /// Custom curve for the scene.
  Curve? curve,
}) {
  assert(
      (begin != null && duration != null && end == null) ||
          (begin != null && duration == null && end != null) ||
          (begin == null && duration != null && end != null) ||
          (begin == null && duration != null && end == null),
      'Please specify two of these properties: begin, duration, end');

  /// Only duration is specified.
  if (duration != null && begin == null && end == null) {
    /// Assume begin is [Duration.zero].
    begin = Duration.zero;
  }

  /// Start and end is specified.
  if (begin != null && end != null) {
    /// Compute duration.
    duration = end - begin;
  }

  /// End and duration is specified.
  if (end != null && duration != null) {
    /// Computing beginning.
    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');

  /// Create scene object.
  var scene = MovieScene(
    begin: begin!,
    duration: duration!,
    curve: curve,
    parent: this,
  );
  _scenes.add(scene);
  return scene;
}