-
Notifications
You must be signed in to change notification settings - Fork 452
Open
Description
Hi @dnfield,
first of all, I'm thrilled by the elegance of your internal design. so it was pretty easy to add an SvgCachedNetworkLoader
class SvgCachedNetworkLoader extends SvgLoader<File> {
/// See class doc.
const SvgCachedNetworkLoader(
this.url, {
this.headers,
super.theme,
super.colorMapper,
});
/// The [Uri] encoded resource address.
final String url;
/// Optional HTTP headers to send as part of the request.
final Map<String, String>? headers;
@override
Future<File> prepareMessage(BuildContext? context) async {
return await _cacheManager.getSingleFile(url, headers: headers);
}
@override
String provideSvg(File? message) {
final Uint8List bytes = message!.readAsBytesSync();
return utf8.decode(bytes, allowMalformed: true);
}
@override
int get hashCode => Object.hash(url, headers, theme, colorMapper);
@override
bool operator ==(Object other) {
return other is SvgCachedNetworkLoader &&
other.url == url &&
other.headers == headers &&
other.theme == theme &&
other.colorMapper == colorMapper;
}
@override
String toString() => 'SvgCachedNetworkLoader($url)';
}Besides that I find it amazing that it is possible to pass a File to compute I wasn't sure if I need to do any special error handling in case prepareMessage or provideSvg throws an exception or if that is totally ok if they do.
Metadata
Metadata
Assignees
Labels
No labels