-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Avoid including a potentially animated invisible image #50842
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
Conversation
liyuqian
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a nit.
| ), | ||
| ])); | ||
| ]))..addStatusListener((AnimationStatus status) { | ||
| if (_placeholderOpacityAnimation.isCompleted) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this always going to be the same as status == AnimationStatus.completed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - the implementation of isCompleted is status == AnimationStatus.completed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh - sorry.
This might not be the same if we've changed the _placeholderOpacityAnimation, but the previous one we were listening to is still finishing.
This is meant to guard against that case, so we don't end up rebuilding unless the current animation is completed.
Description
Currently, FadeInImage continues to build the placeholder even if it's invisible. This is really sad if the placeholder is a multi frame looping animation, or just a large chunk of memory that no one else needs.
Just listening to the animation for the placeholder, when the status is completed for the current animation, setState to trigger a rebuild.
Related Issues
#35592
Tests
I added the following tests:
Test that when the animation completes on the placeholder, it's no longer in the tree.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.