You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can raise the same question about AnimatedWidget. Ultimately it faces the same problem.
Although AnimatedWidget is more honest about its behavior. As AnimatedWidget has its parameter named listenable. While AnimatedBuilder named it animation instead.
These names would be fine if the parameter had for type Animation<T> instead of Listenable.
Maybe an alternative is to keep AnimatedBuilder/Widget but with the type Animation<T>. And change the builder to
Widget animationBuilder(BuildContext context, Widget chid, T value);
And then offer a ListenableBuilder/Widget as a replacement to the current API.
AnimatedWidget used to take an Animation, we changed it to a Listenable much later in its life (when it was first invented, Listenable didn't exist).
Changing this would be a very breaking change, it's probably too late to really make changes here. But it's something we can study when we look at the animation API updates we've discussed.
I'm assuming you linked the wrong PR and are probably referring to #19729. I originally wanted to extract some base class out of the AnimatedBuilder but I think there's something inconvenient in the existing API (where the listable wasn't passed back into the builder closure signature). Since a ValueListenableBuilder is as much an encapsulation mechanism as a triggering mechanism, it would be inappropriate for its owner to pass the listenable back into the builder function instead of being self sufficient.
TL;DR, we're unlikely to rename the AnimatedBuilder and you can consider using the ValueListenableBuilder once the PR is merged.
Regarding the scroll builder, I was thinking of listening ScrollController instead of notifications.
I used this pattern a lot for things like parallax or when I need to align an overlay next to a scroll item. Which wouldn't be possible with notifications.
It would also make it more user friendly then notifications I guess
IMHO we should discuss what possibilities we have here. It's really difficult for beginners to understand that an animation just triggers Listenables and therefore the AnimationBuilder can be used with any Listenable
Please Flutter team, by any means I can't swallow this, it keeps annoying me all the time cause it sounds horribly wrong.
Stream => StreamBuilder
ValueListenable => ValueListenableBuilder
Listenable => AnimatedBuilder
Well, whether or not you guys decide to rename this Class or not, I learned something today 👍
Now I don't need to populate my initState and setState with tons of ScrollController offsets/etc and simply delegate that to AnimatedBuilder for each of my Widgets that need them.
IMO the real confusion is around the member name animation which implies you need an instance of AnimationController and not any controller -- perhaps this is what needs to be changed or made more "generic".
In any case thanks for teaching me something, I feel this a level up in terms of mastering Flutter and should be required reading 💯
Curious why we wouldn't slap an @deprecated on the AnimatedBuilder and replace with ListenableBuilder? After a cpl yrs, pull it out?
While at it, a "plural" version of this would be quite nice as well. Sometimes you have multiple listenables, changing any of them requires a rebuild, nice not to have to nest builders at the same pt in the tree.
Reacted by Kostia Sokolovskyi, icnahom and Lasse Rosenow
While at it, a "plural" version of this would be quite nice as well. Sometimes you have multiple listenables, changing any of them requires a rebuild, nice not to have to nest builders at the same pt in the tree.
Try passing them to Listenable.merge(), and use this listenable in an AnimatedBuilder.
And it would be great if the team accepts your suggestions about slowly moving to ListenableBuilder.
Actually, I'm a bit unsure if we want to create an alias for an existing API (AnimatedBuilder), just for the sake of it being more discoverable. This might confuse API users as well - why are there two classes doing the same thing?
It would not primarily be to make it more discoverable (though that is a side-benefit), it would be so we can write proper semantic code that reads correctly and does not mis-lead the reader. Using something called AnimatedBuilder when no Animation is in play, is just plain confusing.
From a comment above
It's really difficult for beginners to understand that an animation just triggers Listenables and therefore the AnimationBuilder can be used with any Listenable
The duplicated functionality would not really be confusing if AnimatedBuilder is deprecated, and eventually removed after a few yrs.
We have just started using something like this to make semantics more clear:
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
zoechi commentedon Jul 11, 2018
@Hixie
rrousselGit commentedon Jul 11, 2018
We can raise the same question about
AnimatedWidget. Ultimately it faces the same problem.Although
AnimatedWidgetis more honest about its behavior. AsAnimatedWidgethas its parameter namedlistenable. WhileAnimatedBuildernamed itanimationinstead.These names would be fine if the parameter had for type
Animation<T>instead ofListenable.Maybe an alternative is to keep
AnimatedBuilder/Widgetbut with the typeAnimation<T>. And change the builder toAnd then offer a
ListenableBuilder/Widgetas a replacement to the current API.Hixie commentedon Jul 12, 2018
AnimatedWidget used to take an Animation, we changed it to a Listenable much later in its life (when it was first invented, Listenable didn't exist).
Changing this would be a very breaking change, it's probably too late to really make changes here. But it's something we can study when we look at the animation API updates we've discussed.
rrousselGit commentedon Jul 13, 2018
A bit off topic but where can I find that "animation API update discussion"?
zoechi commentedon Jul 25, 2018
Is
#19637#19729 related?xster commentedon Jul 27, 2018
I'm assuming you linked the wrong PR and are probably referring to #19729. I originally wanted to extract some base class out of the AnimatedBuilder but I think there's something inconvenient in the existing API (where the listable wasn't passed back into the builder closure signature). Since a ValueListenableBuilder is as much an encapsulation mechanism as a triggering mechanism, it would be inappropriate for its owner to pass the listenable back into the builder function instead of being self sufficient.
TL;DR, we're unlikely to rename the AnimatedBuilder and you can consider using the ValueListenableBuilder once the PR is merged.
rrousselGit commentedon Jul 28, 2018
That's already a pretty good start, nice !
In the continuation of this PR, would it be valid if I contributed with an
ListenableBuilderandScrollControllerBuilder?Back on the topic, can't we create an AnimationBuilder and mark AnimatedBuilder as
@deprecatedwith other the new builders listed as alternatives ?AnimationBuilder would be fine as name considering it would listen
Animation. Afterall we don't have aStreamedBuilderbutSteamBuilder.xster commentedon Jul 28, 2018
Ha, we actually made one too
#18136 (for scrolling), though we didn't check it in because we weren't sure if people would use it.
Regarding the existing API, like Hixie said, we're unfortunately unlikely to change it.
rrousselGit commentedon Jul 28, 2018
Regarding the scroll builder, I was thinking of listening
ScrollControllerinstead of notifications.I used this pattern a lot for things like parallax or when I need to align an overlay next to a scroll item. Which wouldn't be possible with notifications.
It would also make it more user friendly then notifications I guess
Hixie commentedon Jul 28, 2018
I would recommend making packages for these.
zoechi commentedon Aug 21, 2018
Does #19729 solve this?
9 remaining items
escamoteur commentedon Oct 23, 2019
IMHO we should discuss what possibilities we have here. It's really difficult for beginners to understand that an animation just triggers Listenables and therefore the AnimationBuilder can be used with any Listenable
[-]AnimatedBuilder should be renamed[/-][+]AnimatedBuilder should be renamed [/+]dungnv2602 commentedon Mar 5, 2020
Please Flutter team, by any means I can't swallow this, it keeps annoying me all the time cause it sounds horribly wrong.
Stream => StreamBuilder
ValueListenable => ValueListenableBuilder
Listenable => AnimatedBuilder
ozburo commentedon Mar 28, 2020
Well, whether or not you guys decide to rename this Class or not, I learned something today 👍
Now I don't need to populate my initState and setState with tons of ScrollController offsets/etc and simply delegate that to AnimatedBuilder for each of my Widgets that need them.
IMO the real confusion is around the member name
animationwhich implies you need an instance of AnimationController and not any controller -- perhaps this is what needs to be changed or made more "generic".In any case thanks for teaching me something, I feel this a level up in terms of mastering Flutter and should be required reading 💯
esDotDev commentedon Jan 20, 2021
Curious why we wouldn't slap an @deprecated on the
AnimatedBuilderand replace withListenableBuilder? After a cpl yrs, pull it out?While at it, a "plural" version of this would be quite nice as well. Sometimes you have multiple listenables, changing any of them requires a rebuild, nice not to have to nest builders at the same pt in the tree.
icnahom commentedon Sep 9, 2021
Try passing them to Listenable.merge(), and use this listenable in an AnimatedBuilder.
And it would be great if the team accepts your suggestions about slowly moving to ListenableBuilder.
mateusfccp commentedon Jan 25, 2022
Yeah, I think this is totally doable now. We could simply introduce this:
And then we remove it completely in a later stable version.
I don't think it's much of a hassle...
albertodev01 commentedon Jan 26, 2022
There is a new PR (#97256) to try to solve this issue
esDotDev commentedon Nov 10, 2022
Just to kick the tires on this a bit, #95967 (comment)
It would not primarily be to make it more discoverable (though that is a side-benefit), it would be so we can write proper semantic code that reads correctly and does not mis-lead the reader. Using something called
AnimatedBuilderwhen noAnimationis in play, is just plain confusing.From a comment above
The duplicated functionality would not really be confusing if
AnimatedBuilderis deprecated, and eventually removed after a few yrs.We have just started using something like this to make semantics more clear:
github-actions commentedon Mar 5, 2023
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.