Avoid including a potentially animated invisible image#50842
Merged
dnfield merged 3 commits intoflutter:masterfrom Feb 18, 2020
Merged
Avoid including a potentially animated invisible image#50842dnfield merged 3 commits intoflutter:masterfrom
dnfield merged 3 commits intoflutter:masterfrom
Conversation
This was referenced Feb 15, 2020
tvolkert
reviewed
Feb 18, 2020
| ), | ||
| ])); | ||
| ]))..addStatusListener((AnimationStatus status) { | ||
| if (_placeholderOpacityAnimation.isCompleted) { |
Contributor
There was a problem hiding this comment.
Is this always going to be the same as status == AnimationStatus.completed?
Contributor
Author
There was a problem hiding this comment.
Yes - the implementation of isCompleted is status == AnimationStatus.completed
Contributor
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.