Lets you smoothly animate between two BoxDecoration. Specifically, lets you animate between any color, gradient or image background.
Features
Currently the default implementation in Flutter does not support animating background (BoxDecoration) between color and gradient, two gradient with different type, and anything involving a image.
Usage
If you want to get a intermediate Decoration at progress t between the initial and final Decoration, use:
final Decoration intermediate =
SmoothDecorationTween(begin: begin, end: end).transform(t);
You can also just use the SmoothAnimatedContainer widget just as you use the AnimatedContainer widget:
SmoothAnimatedContainer(
duration: const Duration(seconds: 1),
width: 200,
height: 200,
decoration: toggled ? decoration1 : decoration2,
)
The package only depends on package:flutter/widgets.dart, so it works in apps
that use Material, Cupertino or neither.
Additional information
This package primarily modifies the tweening between two BoxDecoration and focuses on making the animation of the background smooth. The animation of the shape is not implemented. But you can look at the morphable_shape package if you want that functionality.
Libraries
- animated_box_decoration
- Smoothly animate between two
BoxDecorations, including colors, gradients of different types and images.