[英]Cached Network SVG Image
I want to display an SVG picture retrieved from network with the help of Flutter_SVG package and use the same picture in different pages with the Hero widget.我想在Flutter_SVG package的帮助下显示从网络检索到的SVG 图片,并通过 Hero 小部件在不同页面中使用相同的图片。 But each time I use SvgPicture.network() widget, it loads the image again and again from network;
但是每次我使用SvgPicture.network()小部件时,它都会一次又一次地从网络加载图像;
Page 1 & Page 2第 1页和第 2 页
Hero(
tag: 'randomTag',
child: SvgPicture.network(url),
),
I have tried to combine Cached Network Image dependency with Flutter_SVG package but don't know how to use them as a widget together;我尝试将缓存网络图像依赖项与Flutter_SVG package结合使用,但不知道如何将它们一起用作小部件;
Hero(
tag: 'randomTag',
child: CachedNetworkImage(
imageUrl: url,
imageBuilder: (context, ImageProvider<Object> imageProvider) {
// How to use ImageProvider<Object> with SvgPicture?
}
),
),
svg_cached_network_image dependency is not an option since it is not compatible with other dependencies that I use. svg_cached_network_image依赖不是一个选项,因为它与我使用的其他依赖不兼容。
Use flutter_cache_manager to save svg from internet使用flutter_cache_manager从互联网上保存 svg
This line get svg from internet and save it to local, and next time you call it it will get from local此行从互联网上获取 svg 并保存到本地,下次调用它会从本地获取
var file = await DefaultCacheManager().getSingleFile(url);
https://pub.dev/documentation/flutter_cache_manager/latest/flutter_cache_manager/BaseCacheManager/getSingleFile.html https://pub.dev/documentation/flutter_cache_manager/latest/flutter_cache_manager/BaseCacheManager/getSingleFile.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.