Skip to content

Conversation

@tvolkert
Copy link
Contributor

Description

This adds two new builders to the Image class:

  • frameBuilder, which allows callers to control the widget
    created by an [Image].
  • loadingBuilder, which allows callers fine-grained control
    over how to display loading progress of an image to the user.

FadeInImage can be simplified by migrating to the new API.
This is done in follow-on commit.

Related Issues

#32374

Tests

I added full test coverage of the two new properties (verified in merged lcov.info). Specifically:

  • Image invokes frameBuilder with correct frameNumber argument
  • Image invokes frameBuilder with correct wasSynchronouslyLoaded=false
  • Image invokes frameBuilder with correct wasSynchronouslyLoaded=true
  • Image state handles frameBuilder update
  • Image invokes loadingBuilder on chunk event notification
  • Image doesn't rebuild on chunk events if loadingBuilder is null
  • Image chains the results of frameBuilder and loadingBuilder
  • Image state handles loadingBuilder update from null to non-null
  • Image state handles loadingBuilder update from non-null to null

Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read [Handling breaking changes]). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also give the total number of frames then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We won't know that ahead of time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the use case you're considering?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a media progress bar that shows where you are in a looping animated GIF (like the youtube player progress bar)

@tvolkert
Copy link
Contributor Author

PTAL

@goderbauer goderbauer added the framework flutter/packages/flutter repository. See also f: labels. label May 28, 2019
@tvolkert
Copy link
Contributor Author

PTAL

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual implementation LGTM. However, the modification of the template seems odd to me - especially since the modified template isn't even used in this PR?

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This adds two new builders to the `Image` class:

* `frameBuilder`, which allows callers to control the widget
  created by an [Image].
* `loadingBuilder`, which allows callers fine-grained control
  over how to display loading progress of an image to the user.

`FadeInImage` can be simplified by migrating to the new API.
This is done in a follow-on commit.

#32374
@Hixie
Copy link
Contributor

Hixie commented May 29, 2019

LGTM

@tvolkert tvolkert merged commit 6884146 into flutter:master May 29, 2019
@tvolkert tvolkert deleted the image_progress branch May 29, 2019 19:52
@tvolkert
Copy link
Contributor Author

FYI @renefloor in case you find this relevant for cached_network_image

tvolkert added a commit that referenced this pull request May 31, 2019
This updates FadeInImage to use the new Image.frameBuilder
API (added in #33369), to greatly simplify the implementation
of FadeInImage.

This also removes the FadeInImage.placeholderSemanticLabel property.
This property was added in #28799 for the sake of completeness (the bug
it fixed was the lack of any semantic label support in FadeInImage), but a
placeholder is a transient visual artifact, not something that affects the
underlying semantic meaning of the image.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants