Effect<T extends AnimatedParticle> class abstract

An abstract class representing an effect that emits particles for animations in Newton.

Extend this class to create custom particle effects. Subclasses must implement the instantiateParticle method to define how particles are emitted and their behavior. The Effect class provides the framework for creating visually stunning animations with particles that can be customized based on your specific requirements.

Example:

class CustomEffect extends Effect<AnimatedParticle> {
  @override
  AnimatedParticle instantiateParticle(Size surfaceSize) {
    // Define the behavior of particles during emission.
    // Set particle positions, travel paths, and animation properties here.
  }
}

The Effect class is used with the NewtonEmitter widget to create captivating animations in your Flutter application. By implementing the instantiateParticle method, you have full control over particle properties, such as emission frequency, particle appearance, movement, and animation. This allows you to achieve a wide range of stunning visual effects, such as rain, smoke, explosions, and more.

Implementers

Constructors

Effect({required ParticleConfiguration particleConfiguration, required EffectConfiguration effectConfiguration})

Properties

activeParticles List<AnimatedParticle>
Immutable List of active particles managed by the effect.
no setter
addedAtRuntime bool
getter/setter pair
effectConfiguration EffectConfiguration
Configuration for the effect. See EffectConfiguration.
final
foreground bool
Should the effect be played in foreground?
no setter
hashCode int
The hash code for this object.
no setterinherited
particleConfiguration ParticleConfiguration
Configuration for particle properties. See ParticleConfiguration.
final
postEffectCallback ValueChanged<Effect<AnimatedParticle>>?
Register a callback if you want to be notified that a post effect is occurring
getter/setter pair
random Random
Random number generator for particle properties.
final
rootEffect Effect<AnimatedParticle>
Root effect that triggered this effect
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state EffectState
Current state of the effect
no setter
stateChangeCallback ← (void Function(Effect<AnimatedParticle>, EffectState)?)
Callback to be notified when state has changed
no getter
surfaceSize Size
Sets the size of the animation surface.
no getter
totalElapsed double
Total elapsed time since the effect started.
getter/setter pair

Methods

forward(int elapsedMillis) → dynamic
Advances the effect animation based on the elapsed time in milliseconds. This method is automatically called to update the particle animation.
instantiateParticle(Size surfaceSize) AnimatedParticle
Abstract method to be implemented by subclasses to define particle emission behavior.
kill() → dynamic
Kills the effect, stopping all particle emission and removing active particles.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
randomAngle() double
Helper method to generate random angle within the range EffectConfiguration.minAngle - EffectConfiguration.maxAngle.
randomDistance() double
Helper method to generate random distance within the range EffectConfiguration.minDistance - EffectConfiguration.maxDistance.
randomDuration() int
Helper method to generate random duration within the range EffectConfiguration.minDuration - EffectConfiguration.maxDuration.
randomFadeInLimit() double
Helper method to generate random fadeIn limit within the range EffectConfiguration.minFadeInLimit - EffectConfiguration.maxFadeInLimit
randomFadeOutThreshold() double
Helper method to generate random fadeOut threshold within the range EffectConfiguration.minFadeOutThreshold - EffectConfiguration.maxFadeOutThreshold
randomScaleRange() Tween<double>
Helper method to generate random scale range within the range (EffectConfiguration.minBeginScale - EffectConfiguration.maxBeginScale)
start() → dynamic
Starts the effect emission, allowing particles to be emitted.
stop({bool cancel = false}) → dynamic
Stops the effect emission, optionally cancelling all active particles.
toString() String
A string representation of this object.
inherited

Operators

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