Skip to content

ImageProvider wrappers should override createStream-method #107000

Closed

Description

@Klabauterman

Use case

I wrote my own CustomImageProvider class which does override createStream to return its own subclass of ImageStream. But if I use the build-in Image-widget, it wraps my CustomImageProvider with a ScrollAwareImageProvider. ScrollAwareImageProvider does not override createStream to return the ImageStream of CustomImageProvider. The createStream-method of CustomImageProvider will never be called!

The background is that I wanted to build a NetworkImageProvider that is able to cancel requests when the corresponding Image-widget gets disposed.

Proposal

Image provider wrappers ScrollAwareImageProvider and ResizeImage should override createStream like this:

@override
ImageStream createStream(ImageConfiguration configuration) {
  imageProvider.createStream(configuration);
}

Activity

  1. added
    in triagePresently being triaged by the triage team
    c: new featureNothing broken; request for a new capability
    frameworkflutter/packages/flutter repository. See also f: labels.
    c: proposalA detailed proposal for a change to Flutter
    and removed
    in triagePresently being triaged by the triage team
    on Jul 4, 2022
  2. goderbauer commented on Jul 6, 2022

    @goderbauer
    Member
  3. added
    f: scrollingViewports, list views, slivers, etc.
    a: imagesLoading, displaying, rendering images
    P3Issues that are less important to the Flutter project
    and removed
    c: new featureNothing broken; request for a new capability
    c: proposalA detailed proposal for a change to Flutter
    on Jul 6, 2022
  4. dnfield commented on Jul 6, 2022

    @dnfield
    Contributor

    I think this is just an oversight in the implementation and should be an easy fix.

    both ResizeImage and ScrollAwareImageProvider should be updated to override missing virtual overrides to delegate to the wrapped provider.

  5. dnfield commented on Jul 6, 2022

    @dnfield
    Contributor

    If you want to put up a patch that does this (with a test) I'd be happy to review.

  6. dnfield commented on Jul 6, 2022

    @dnfield
    Contributor

    Alternatively, maybe we should have a VirtualImageProvider abstract class that helps with this, and then ResizeImage and ScrollAwareImageProvider could both extend that...

  7. Levi-Lesches commented on Nov 16, 2022

    @Levi-Lesches
    Contributor

    @Klabauterman, what was your workaround? My use case is implementing my own ImageProvider to update to new images as they arrive over the network (like a video sent frame by frame), but createStream is never being called.

    EDIT I found that Image uses RawImage under the hood, so I switched to that, and now I can achieve my goal of flipping images in under 0.25 seconds, consistently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: imagesLoading, displaying, rendering imagesf: scrollingViewports, list views, slivers, etc.frameworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions