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

[BUG] Caching is not working correctly. #1074

Open
darkstarx opened this issue May 30, 2024 · 0 comments
Open

[BUG] Caching is not working correctly. #1074

darkstarx opened this issue May 30, 2024 · 0 comments

Comments

@darkstarx
Copy link

You use SvgCacheKey that has keyData which is SvgNetworkLoader.

  1. Implement operator== and hashCode for ColorMapper (actually there is only TestColorMapper yet).
  2. Fix calculating hashCode and comparing the SvgNetworkLoader.headers which is Map<String, String>.
  @override
  int get hashCode => Object.hash(url, headers /* HERE */, theme, colorMapper);

  @override
  bool operator ==(Object other) {
    return other is SvgNetworkLoader &&
        other.url == url &&
        other.headers == headers &&  // You NEVER get here true until these are identical maps.
        other.theme == theme &&
        other.colorMapper == colorMapper;
  }

It's hardly ever to be happend when user writes the same Map of headers on different pages, usually these are different maps with the same entries.

You have two options:

  1. Use const MapEquality().equals(headers, other.headers) in the operator== and Object.hashAll([ ...headers.keys, headers.values, ... ]) in the hashCode getter.
  2. Remove headers from hashCode and operator== since headers don't define the the source of svg data like url does.
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

No branches or pull requests

1 participant