AnimationOnScrollController constructor
AnimationOnScrollController({
- required ScrollController? scrollController,
- AnimationDirection direction = AnimationDirection.forward,
- double requiredScrollOffset = 32.0,
- required TickerProvider vsync,
- Duration animationDuration = const Duration(milliseconds: 130),
Creates an AnimationOnScrollController.
-
scrollController obtains the current scroll offset.
-
direction is the direction in which the animation is played.
-
requiredScrollOffset is the offset required to trigger the animation.
-
vsync provides access to the current TickerProvider to initialize the AnimationController.
-
animationDuration will determine the length the animation should have.
{@tool snippet} The AnimationOnScrollController needs to be initialized on a StatefulWidget. This can be achieved by initializing the declared object in the State.initState method as stated below:
_animationOnScrollController = AnimationOnScrollController(
scrollController: _scrollController,
vsync: this,
);
{@end-tool}
{@tool snippet} The AnimationOnScrollController should also be disposed by overriding the State.dispose method as stated below:
_animationOnScrollController.dispose();
{@end-tool}
Implementation
AnimationOnScrollController({
required this.scrollController,
this.direction = AnimationDirection.forward,
this.requiredScrollOffset = 32.0,
required this.vsync,
this.animationDuration = const Duration(milliseconds: 130),
}) {
_initAnimation();
_attach();
}