Skip to content

fix: include decoding dimensions in BlurHashImage cache keys - #80

Open
ananya-kaul wants to merge 1 commit into
fluttercommunity:masterfrom
ananya-kaul:ananya/fix-blurhash-cache-dimensions
Open

ananya-kaul wants to merge 1 commit into
fluttercommunity:masterfrom
ananya-kaul:ananya/fix-blurhash-cache-dimensions

Conversation

@ananya-kaul

Copy link
Copy Markdown

Summary

Include decodingWidth and decodingHeight in BlurHashImage equality and hashCode.

obtainKey returns the provider itself. Previously, providers with the same hash and scale compared equal even when they requested different decoding dimensions. Flutter's image cache could therefore reuse a decoded image with the wrong dimensions, and changing the dimensions could leave an existing Image using its old stream.

For example, a 16×16 request and a 128×128 request for the same hash and scale currently produce equal keys, despite decoding different images.

Compare both dimensions and include them in the hash code. Requests with identical settings still share cached images. This only changes cache identity; it does not change the decoder or public constructor.

Reference: Flutter's ImageProvider key contract.

Validation

  • dart analyze lib/src/blurhash_image.dart — no issues found.
  • git diff --check — passed.
  • Tests were not run.

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.

1 participant