Here is my use case:
Our app is working offline as well. I tried a few libraries like flutter_advanced_networkimage
and flutter_cache_manager
but I'm getting quite lag and most of the times app crash.
Save it in your app's temp directory:
import 'dart:io';
// https://pub.dev/packages/path_provider
import 'package:path_provider/path_provider.dart';
final Directory temp = await getTemporaryDirectory();
final File imageFile = File('${temp.path}/images/someImageFile.png');
if (await imageFile.exists()) {
// Use the cached images if it exists
} else {
// Image doesn't exist in cache
await imageFile.create(recursive: true);
// Download the image and write to above file
...
}
It will persist through app launches and only gets deleted when the user personally clears the cache or reinstalls the app.
I've been using cached_network_image
, works as advertised
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With