Using AnimatedBuilder
Looking at the code that we wrote in the last section, there is nothing wrong with it: it's not too complex or big. However, looking closely, we can see a small problem with it, our button animation is mixed up with other widgets. As long as our code does not scale and get more complex, this is fine, but we know this is not the case most of the time, so we might have a real problem.
The AnimatedBuilder class can help us with the task of separating responsibilities; our widget, whether it is RaisedButton or anything else, does not need to know it is rendered in animation, and breaking down the build method to widgets that each have a single responsibility can be seen as one of the fundamental lemmas in the Flutter framework. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access