EffectController class abstract

Base "controller" class to facilitate animation of effects.

The purpose of an effect controller is to define how an Effect or an animation should progress over time. To facilitate that, this class provides variable progress, which will grow from 0.0 to 1.0. The value of 0 corresponds to the beginning of an animation, and the value of 1.0 is the end of the animation.

The progress variable can best be thought of as a "logical time". For example, if you want to animate a certain property from value A to value B, then you can use progress to linearly interpolate between these two extremes and obtain variable x = A*(1 - progress) + B*progress.

The exact behavior of progress is determined by subclasses, but the following general considerations apply:

  • the progress can also go in negative direction (i.e. from 1 to 0);
  • the progress may oscillate, going from 0 to 1, then back to 0, etc;
  • the progress may change over a finite or infinite period of time;
  • the value of 0 corresponds to the logical start of an animation;
  • the value of 1 is either the end or the "peak" of an animation;
  • the progress may briefly attain values outside of [0; 1] range (for example if a "bouncy" easing curve is applied).

An EffectController can be made to run forward in time (advance()), or backward in time (recede()).

Unlike the dart.ui.AnimationController, this class does not use a Ticker to keep track of time. Instead, it must be pushed through time manually, by calling the update() method within the game loop.

Implementers

Constructors

EffectController({double? duration, double? speed, Curve curve = Curves.linear, double? reverseDuration, double? reverseSpeed, Curve? reverseCurve, bool infinite = false, bool alternate = false, int? repeatCount, double startDelay = 0.0, double atMaxDuration = 0.0, double atMinDuration = 0.0})
Factory function for producing common EffectControllers.
factory
EffectController.empty()

Properties

completed bool
Has the effect already finished?
no setter
duration double?
Total duration of the effect. If the duration cannot be determined, this will return null. For an infinite effect the duration is infinity.
no setter
hashCode int
The hash code for this object.
no setterinherited
isInfinite bool
Will the effect continue to run forever (never completes)?
no setter
isRandom bool
Is the effect's duration random or fixed?
no setter
progress double
The current progress of the effect, a value between 0 and 1.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
started bool
Has the effect started running? Some effects use a "delay" parameter to postpone the start of an animation. This property then tells you whether this delay period has already passed.
no setter

Methods

advance(double dt) double
Advances this controller's internal clock by dt seconds.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onMount(Effect parent) → void
This is called by the Effect class when the controller is attached to that effect. Controllers with children should propagate this to their children.
recede(double dt) double
Similar to advance(), but makes the effect controller move back in time.
setToEnd() → void
Puts the controller into its final "completed" state.
setToStart() → void
Reverts the controller to its initial state, as it was before the start of the animation.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited