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

feat: Add support for base64 encoded images to be manually added to Images cache. #3008

Merged
merged 2 commits into from
Jan 28, 2024

Conversation

erickzanardo
Copy link
Member

Description

Adds a method so base64 encoded images can be manually added to the Images cache.

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Replace or remove this text.

@erickzanardo erickzanardo requested a review from a team January 28, 2024 13:53
@@ -49,6 +49,14 @@ class Images {
_assets[name] = _ImageAsset.fromImage(image);
}

/// Transform the base64 encoded image into an [Image] and adds it into the
/// cache.
Future<void> addBase64EncodedImage(String name, String base64Data) async {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Future<void> addBase64EncodedImage(String name, String base64Data) async {
Future<void> addFromBase64Data(String name, String base64Data) async {

Maybe? That it's an image should already be implicit from the cache name

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed! updated

@erickzanardo erickzanardo merged commit 1e56293 into main Jan 28, 2024
8 checks passed
@erickzanardo erickzanardo deleted the erick.add-base64-image branch January 28, 2024 14:16
@spydon
Copy link
Member

spydon commented Jan 30, 2024

@erickzanardo I just stumbled upon this method which is already in the Images class:
image
Doesn't that do the same thing, except with the missing dispose?

@erickzanardo
Copy link
Member Author

@spydon not really, that method will fetch from cache if the image is already there, the method that I introduced will always force the cache to be updated.

@spydon
Copy link
Member

spydon commented Jan 30, 2024

@spydon not really, that method will fetch from cache if the image is already there, the method that I introduced will always force the cache to be updated.

Ah, alright, it seems like it should just have been a flag to this method instead of a new method then?

We should really standardize how the caches work for V2, it feels quite unstructured now.

@erickzanardo
Copy link
Member Author

Yeah, agree on the flag, that was what I thought at first, but I preferred to follow the other method add that already exists to keep the consistency.

@spydon
Copy link
Member

spydon commented Jan 30, 2024

Yeah, agree on the flag, that was what I thought at first, but I preferred to follow the other method add that already exists to keep the consistency.

Makes sense, I'll put it in the V2 list that we should look through the cache classes :)

@erickzanardo
Copy link
Member Author

Sounds good!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants