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

Constructors

InjectedAnimation()

Properties

autoDisposeWhenNotUsed bool
no setterinherited
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
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 observers
no setterinherited
isActive bool
Whether the state is active 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
oldSnapState SnapState<double>
no setterinherited
rebuild → _RebuildAnimation
Listen to the InjectedAnimation and rebuild when animation ticks.
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
snapState SnapState<double>
A snap representation of the state
getter/setter pairinherited
state double
no setterinherited
stateAsync Future<double>
It is a future of the state. The future is active if the state is on the isWaiting status.
no setterinherited

Methods

dispose() → void
Dispose the state.
inherited
initializeState() FutureOr<double?>
Initialize the state
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent 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