animated_to 0.1.0 copy "animated_to: ^0.1.0" to clipboard
animated_to: ^0.1.0 copied to clipboard

AnimateTo animates its child to a new position requiring no calculation.

animated_to #

animated_to provides a widget named AnimatedTo.

AnimatedTo Preview

AnimatedTo enables you to animate whatever widget you want to animate to the next position when rebuild happens and the rebuild updates the position of the widget.

No calculation is necessary. Every calculation is done by Flutter framework, and AnimatedTo just animates to the calculated position.

Usage #

First, place whatever widget you want to animate when its position changes.

Container(
  width: 60,
  height: 60,
  color: Colors.blue,
)

Then, wrap the widget with AnimatedTo with some required arguments.

AnimatedTo(
  key: _globalKey,
  vsync: this,
  child: Container(
    width: 60,
    height: 60,
    color: Colors.blue,
  ),
)

key is GlobalKey to keep its Element and RenderObject alive even when the widget is placed at another branch of the widget tree.

vsync requires TickerProviderStateMixin for animation. You may typically mixin TickerProviderStateMixin in your State class of StatefulWidget.

That's it!

All what you need to do is causing rebuilds using whatever state management packages or just setState and change its position. AnimatedTo will automatically leads the child to the new position with animation.

All arguments #

Argument Type Description
key GlobalKey A key to identify the widget even when it's placed at another branch of the widget tree.
vsync TickerProviderStateMixin A ticker provider to provide animation.
child Widget The widget to animate.
duration Duration The duration of the animation.
curve Curve The curve of the animation.
appearingFrom Offset? The start position of the animation in the first frame. This offset is an absolute position in the global coordinate system.
slidingFrom Offset? The start position of the animation in the first frame. This offset is a relative position to the child's intrinsic position.
enabled bool Whether the animation is enabled. Be sure to set false when scrolling. Otherwise, the scrolling will look like jerky.
onEnd void Function(AnimationEndCause cause)? The callback when the animation is completed. cause shows the reason why the animation is completed.

See example for more details.

Or, see my X account @chooyan_i18n posting some example screenshots.

Contact #

If you have anything you want to inform me (@chooyan-eng), such as suggestions to enhance this package or functionalities you want etc, feel free to make issues on GitHub or send messages on X @tsuyoshi_chujo (Japanese @chooyan_i18n).

82
likes
0
points
516
downloads

Publisher

unverified uploader

Weekly Downloads

AnimateTo animates its child to a new position requiring no calculation.

Repository (GitHub)
View/report issues

Topics

#animation

License

unknown (license)

Dependencies

flutter

More

Packages that depend on animated_to