Back to results for “Implicit vs Explicit Animations”
Flutter › Implicit vs Explicit Animations

How does the TweenAnimationBuilder widget genuinely let you achieve a considerably more custom implicit animation effect, without actually needing to fully write out an entirely separate fully custom implicit animation widget class completely from scratch yourself?

Advanced

Answer

TweenAnimationBuilder provides a genuinely convenient middle ground option positioned somewhere between the fully pre built implicit animation widgets, such as AnimatedContainer, and manually managing your own genuinely fully explicit AnimationController completely yourself, letting you properly define your own specific custom Tween and a corresponding builder function that gets automatically called on essentially every single frame as that particular animation's own value smoothly changes, effectively giving you the genuine simplicity of an implicit animation while still allowing you to genuinely animate essentially any arbitrary custom property that none of Flutter's own existing pre built implicit widgets already directly and specifically support.
TweenAnimationBuilder<double>(
  tween: Tween(begin: 0, end: targetRotation),
  duration: Duration(milliseconds: 500),
  builder: (context, value, child) => Transform.rotate(angle: value, child: child),
)
Real-world example A custom compass widget uses TweenAnimationBuilder to smoothly animate its own particular rotation angle whenever a new target heading value is actually received, achieving the genuine simplicity of an implicit animation for a genuinely custom specific property that no existing pre built Flutter implicit widget already directly supports.

Common follow-ups: How does TweenAnimationBuilder actually genuinely differ internally from directly using AnimatedBuilder together with a manually managed AnimationController?;What genuinely happens if the specific Tween's own begin and end values actually keep changing repeatedly and quite rapidly?