Add new optional cacheKeyResolver
This PR adds an optional parameter to AudioService.init() that allows specifying a cacheKeyResolver function which specifies how a cache key is resolved for a given MediaItem's art with the cache manager. If no method is specified, the current behavior is kept (the URL is used as the cache key).
This new method allow custom cache key implementations to better support situations where the URL may not be suitable as a cache key. It also brings parity with other packages like cached_network_image which also allows specifying a custom cache key, so if you're using the same cache manager across both libraries you can also use the same cache keys.
Fixes #1001.
Pre-launch Checklist
- [x] I read the [CONTRIBUTING.md] and followed the process outlined there for submitting PRs.
- [x] My change is not breaking and lands in
minorbranch OR my change is breaking and lands inmajorbranch. - [x] If I'm the first to contribute to the next version, I incremented the version number in
pubspec.yamlaccording to the [pub versioning philosophy]. - [x] I updated CHANGELOG.md to add a description of the change (format:
* DESCRIPTION OF YOUR CHANGE (@your-git-username)). - [x] I updated/added relevant documentation (doc comments with
///). - [x] I ran
dart analyze. - [x] I ran
dart format. - [x] I ran
flutter testand all tests are passing.
@ryanheise any thoughts on this API/implementation?