InjectedAnimation class abstract

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),
              );
            },
          ),
    
Available extensions

Constructors

InjectedAnimation()

Properties

controller → AnimationController?
Get the AnimationController associated with this InjectedAnimation
no setter
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)
no setter
customStatus ↔ Object?
Custom status of the state. Set manually to mark the state with a particular tag to be used in your logic.
getter/setter pairinherited
error → dynamic
The error
no setterinherited
hasData → bool
The state is mutated successfully.
no setterinherited
hasError → bool
The stats has error
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
hasObservers → bool
Whether the state has listeners or not
no setterinherited
isDone → bool
The state is mutated using a stream and the stream is done.
no setterinherited
isIdle → bool
The state is initialized and never mutated.
no setterinherited
isWaiting → bool
The state is waiting for and asynchronous task to end.
no setterinherited
rebuild → _Rebuild

Available on InjectedAnimation, provided by the InjectedAnimationX extension

no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
snapState → SnapState<double>
A snap representation of the state
no setterinherited

Methods

addCleaner(VoidCallback listener) → VoidCallback
Add a callback to be executed when the state is disposed of.
inherited
addObserver({required ObserveReactiveModel listener, bool shouldAutoClean = false, bool isSideEffects = true}) → VoidCallback
Add observer to this state.
inherited
cleanState() → void
Clean the state
inherited
dispose() → void
Dispose the state
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify() → void
Notify observers
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