Closed veresvit closed 4 years ago
You can precache the provider with precacheImage.
You can precache the provider with precacheImage.
Yes, but the problem with this approach is, that it would need a BuildContext instance. It would be cool to take care of this pre caching in a data layer, or some kind of repository. Not in the UI layer with BuildContext.
Any chance for this upgrade or should I take care of it in the UI context?
Thank you
import 'package:flutter_advanced_networkimage/src/utils.dart';
import 'package:flutter_advanced_networkimage/src/disk_cache.dart';
Uint8List data = await loadFromRemote(
url,
null,
5,
const Duration(milliseconds: 500),
1.5,
const Duration(seconds: 5),
null,
null,
);
if (data != null) {
await diskCache.save(uid(url), data, cacheRule);
}
Awesome, thank you so much! Will try it.
Will you consider it as a first level API for your library, instead of just hoving to use internal implementation?
AdvancedNetworkImage(...).loadFromRemote()
was added in 0.6.0
.
Do you have a more detailed example on how to pre-cache images?
There is no loadFromRemote
method on AdvancedNetworkImage
, only the one in utils
.
And diskCache
, should I create my own global singleton instance of discCache to populate here with images? Or there is already an instance used internally that I should use?
Also, should I wrap work with the disc cache into isolate? I tried with above example and my UI seems to be completely frozen
Hello, it would be nice if we can "pre feed" the AdvancedNetworkImage with images to cache even before the actual rendering occurs.
Use case: A configuration file for the app contains a list of image urls to be used in the app. If we pre cache the images off screen (while the app is running, but the actual image widget is not yet visible) the user will have much nicer experience when the actual widget is rendered, instead of seeing a loading widget. This is especially important if the user doesn't open the desired part of the app while on a network but these images should be available offline later on.
Thank you for considering this update.