-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optionally wrap Animate
with RepaintBoundary
#46
Comments
I would love to see this proposal accepted and implemented. I think this addition would align perfectly with the already existing mindset of Flutter, that is, to make it as easy to write performant code as possible. |
@gskinner I created a small draft PR and decided not to include the parameter in |
Thanks @S-ecki ! I think that's a good call, if you have a list of animated items, it's usually not going to be a good candidate for wrapping each item in RepaintBoundary. I'm coding on some other stuff right now, but will aim to look over the PR in the next day or so. |
just a note that this is still on list to fully review, just working through a few other items first. |
Looked this over, and it looks good, but I want to make sure there's a good answer for one simple question before including this: "why?" What is the ultimate goal for this feature? It's not any shorter or easier than just wrapping in a widget: foo.animate(useRepaintBoundary: true)
// vs
RepaintBoundary(child: foo.animate()) I have an idea or two of why it might be justified, but I'd be interested to hear other thoughts on this (versus, for example, just adding a note in the README about RepaintBoundary). Sorry for not asking this sooner, it just occurred to me while reviewing the PR tonight. :) |
quick note @gskinner, I'm in Australia backpacking rn, will answer as soon as I'm back :) |
I think the
|
Reasoning
As discussed in this talk about
flutter_animate
, the performance of animations might get significantly improved by wrapping them in a RepaintBoundary.I argue that this is not apparent to everyone. Especially newer Flutter developers might not be aware of this performance improvement opportunity.
Proposal
Add an optional
bool? useRepaintBoundary
to theAnimate()
widget. If set true, the animation should be automatically wrapped with aRepaintBoundary
. The parameter should be false by default, as RepaintBoundaries also come with a cost and the usage should be transparent.It would be vital to also add extensive explanation in the documentation of the parameter about when to use
RepaintBoundary
and when not to, optimally with examples. This way, people not knowing about the widget would get educated and situations whereRepaintBoundary
is applied suboptimally get minimized (although not eliminated!).If the addition of such a parameter comes with too high of a risk of missusage, I propose to at least add a section to the ReadMe/Docs of this package explaining the potential benefits and drawbacks of using a
RepaintBoundary
in combination with animations.Additional Context
This matter was discussed briefly in this tweet with the author of the package.
The text was updated successfully, but these errors were encountered: