Skip to content
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

extend OctoImage-->imageBuilder to also include the imageprovider #13

Open
rooscarljohan opened this issue Oct 18, 2020 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@rooscarljohan
Copy link

Great package!

Sometimes it is also valuable to obtain the imageprovider in the imageBuilder constructor.

Currently it looks like this:
typedef OctoImageBuilder = Widget Function(BuildContext context, Widget child);

Hence I'd like it changed to
typedef OctoImageBuilder = Widget Function(BuildContext context, Widget child, Imageprovider image);

Had a look at CachedNetworkImage, and did a workaround:

  ImageProvider imageProvider =...

   return OctoImage(
    image: imageProvider,
     ...
    imageBuilder: (context, _) => here i'm using the imageProvider
  );

but would be more slick to have the imageprovider directly in the imageBuilder's constructor

@renefloor
Copy link
Collaborator

I see why you'd want this. However, the workaround in CachedNetworkImage is really a workaround and I think it needs some more work to make a decent implementation. The problem is that in this work around the ImageProvider is used to create an Image Widget which you then throw away to create a new image widget. It is not that bad that it can't be used as a workaround, but I think we need to clone the image widget to do the loading and creation of the widget ourselves.

@rooscarljohan
Copy link
Author

Thanks. And agree - the workaround isn't really great.

What about providing dual constructors

  1. imageProviderBuilder (context, imageProvider)
  2. imageBuilder (context, image-widget)

and assess XOR !=null between the two?

then you can decide what to provide, an image-widget OR an imageProvider

@renefloor
Copy link
Collaborator

Yes that would be nice, but still we need to rewrite the core flutter image widget to not create an image widget twice. I don't like making such a builder using the workaround hack.

@renefloor renefloor added the enhancement New feature or request label Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants