InjectedAnimation class Null safety

Inject an animation. It works for both implicit and explicit animation.

This injected state abstracts the best practices to come out with a simple, clean, and testable approach to manage animations.

The approach consists of the following steps:

  • Instantiate an InjectedAnimation object using RM.injectAnimation method.
      final animation = RM.injectAnimation(
        duration: Duration(seconds: 2),
        curve: Curves.fastOutSlowIn,
      );
    
  • Use OnAnimationBuilder to listen to the InjectedAnimation. the builder of OnAnimationBuilder exposes an Animate object used to set tweens explicitly or implicitly method.
          child: OnAnimationBuilder(
            listenTo: animation,
            builder: (animate) {
              //Implicit animation
              final width = animate(selected ? 200.0 : 100.0);
    
              // Explicit animation
              final height = animate.fromTween((_)=> Tween(200.0, 100.0));
    
              return Container(
                width: width,
                height: height,
                child: const FlutterLogo(size: 75),
              );
            },
          ),
    

Constructors

InjectedAnimation()

Properties

autoDisposeWhenNotUsed bool
read-only, inherited
controller AnimationController?
Get the AnimationController associated with this InjectedAnimation
read-only
curvedAnimation Animation<double>
Get default animation with Tween<double>(begin:0.0, end:1.0) and with the defined curve, Used with Flutter's widgets that end with Transition (ex SlideTransition, RotationTransition)
read-only
error → dynamic
The error
read-only, inherited
hasData bool
The state is mutated successfully.
read-only, inherited
hasError bool
The stats has error
read-only, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
hasObservers bool
Whether the state has observers
read-only, inherited
isActive bool
Whether the state is active or not. [...]
read-only, inherited
isDone bool
The state is mutated using a stream and the stream is done.
read-only, inherited
isIdle bool
The state is initialized and never mutated.
read-only, inherited
isWaiting bool
The state is waiting for and asynchronous task to end.
read-only, inherited
oldSnapState SnapState<double>
read-only, inherited
rebuild → _RebuildAnimation
Listen to the InjectedAnimation and rebuild when animation ticks. [...]
late, final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
snapState SnapState<double>
A snap representation of the state
read / write, inherited
state double
read-only, inherited
stateAsync Future<double>
It is a future of the state. The future is active if the state is on the isWaiting status.
read-only, inherited

Methods

dispose() → void
Dispose the state.
inherited
initializeState() FutureOr<double>
Initialize the state
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
notify() → void
Notify observers
inherited
onAll<R>({R onIdle()?, required R onWaiting()?, required R onError(dynamic error, VoidCallback refreshError)?, required R onData(double data)}) → R
inherited
onOrElse<R>({R onIdle()?, R onWaiting()?, R onError(dynamic error, VoidCallback refreshError)?, R onData(double data)?, required R orElse(double data)}) → R
inherited
refresh() Future<double>
Update On.animation widgets listening the this animation [...]
resetAnimation({Duration? duration, Duration? reverseDuration, Curve? curve, Curve? reverseCurve, int? repeats, bool? shouldReverseRepeats}) → void
Used to change any of the global parameters fo the animation such as duration, reverseDuration, curve, reverseCurve, repeats and shouldReverseRepeats. [...]
toString() String
A string representation of this object. [...]
inherited
triggerAnimation({bool restart = false}) Future<void>?
Start animation. [...]

Operators

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