Hey,
you are close with your reasoning because it’s not that AnimatedBuilder
requires Opacity
but Opacity
to be animated requires AnimatedBuilder
, here is the reason:
First the difference between Opacity
and FadeTransition
.
Opacity is backed up by RenderObject
called RenderOpacity
, whereas FadeTransition
is backed up by RenderAnimatedOpacity
.
Both of those widgets need to be provided with double
value of opacity and some sort of notification that they need to update themselves.
In the case of FadeTransition
, we provide both of this in Animation<double>
and animation is a Listenable
aka change notifier that the RenderAnimatedOpacity
subscribes to.
In the case of Opacity
we are only providing double
and we need to use setState
or better AnimatedBuilder
to notify Opacity that it needs to repaint.
Other then that RenderOpacity
and RenderAnimatedOpacity
are really similar.
For me, when doing opacity animations, FadeTransition
is easier to use and a bit more performant (no rebuild of AnimatedBuilder
).
Hopefully, this clears things up for you.
Cheers!