Flutter Developer
Hey guys!
TL;DR: Can you give me an advice for caching images from appwrite storages?
I am developing an App in Flutter. I want to fetch images from the appwrite storage. Currently i am using the suggested way to implement preview images like written here: https://appwrite.io/docs/client/storage?sdk=flutter-default#storageGetFileView But i would like to Cache them after i downloaded them once. I only found the plugin cached_network_image for that, but with that i have to add an header as my pictures are not public. (like here https://stackoverflow.com/questions/73770036/caching-images-thumbnails-in-listview ). But i really would like to avoid that and use as much from appwrites out-of-the-box-solutions as possible.
Current solution:
return FutureBuilder(
future: storage.getFileView(
bucketId: BUCKET_IMAGES_ID,
fileId: FILE_ID,
),
builder: (context, snapshot) {
return snapshot.hasData && snapshot.data != null
? Image.memory(
snapshot.data,
fit: BoxFit.cover,
)
: snapshot.hasError
? Image.asset(
"assets/images/testbild.jpg",
fit: BoxFit.cover,
)
: Image.asset(
"assets/images/testbild.jpg",
fit: BoxFit.cover,
);
},
);
}