I am iterating through a listview of objects and retrieving favicon URL's from package:favicon/favicon.dart as a future:
in a FutureBuilder
. I then use these URL's to return and cache the favicon images in containers as leading listtile icons with a CachedNetworkImageProvider.
This works great, however it takes time to load every time the listview is refreshed because it has to retrieve the best url from the favicon url getter.
How do I cache the future: value so that there is no delay in using the URL retriever after the first use. Here is the code:
return new ListTile(
leading:
FutureBuilder(
future: iconz.Favicon.getBest(urlBase),
builder: (context, snapShot2) {
if (snapShot2.hasData){
String urlIcon = snapShot2.data.url.toString();
var containImage = Container(
height: 40,
width: 40,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: CachedNetworkImageProvider(urlIcon),
fit: BoxFit.fill
),
),
);
return containImage;
}
else {
return
const Icon(Icons.remove_red_eye, color: Color(0xff00caff), size: 40);
}
}
),
title: ...
In summary: How to use flutter_cache_manager on future: iconz.Favicon.getBest(urlBase),
?