cached_firestorage 0.1.1 cached_firestorage: ^0.1.1 copied to clipboard
A Flutter utility that manages Firebase Storage download URLs and caches the results
Cached Firestorage #
A Flutter utility that manages Firebase Storage download URLs and caches the results
Usage #
Cached Firestorage exposes a Singleton
that you can access via CachedFirestorage.instance
The default cache duration
is of 360s
(6h
): you can customize this by passing the number of seconds to the instance:
CachedFirestorage.instance.cacheTimeout = 30;
APIs #
getDownloadURL #
This is the main api: it's a Future<String>
that resolves returning in its snapshot.data
the Firebase Storage's download url of the requested resource,
and caches the result, so every time you will ask for it again, you'll have direct access to the resource's url.
getDownloadURL
always returns a String
, meaning that if no file is matched and no fallbackFilePath
(see below) is provided, it will return ''
;
Parameters (all named)
String mapKey
: The key at which your cached entry will be storedString filePath
: The file path on your Firebase Storage bucketString? storageKey
: You can split the cache into sub-paths: this is the subpath keyString? fallbackFilePath
: If provided, this is the path that will be returned in case of no matches on Firebase Storage
removeCacheEntry #
By calling this api you can remove a cache entry when you want. Very useful in case you need to update the download URL of a previously stored resource before the cache expires.
Parameters (all named)
String mapKey
: the key to be removed from the cacheString? storageKey
: the storage key in which Cached Firestorage should search the mapKey
Widgets #
RemotePicture #
Since Firebase Storage is particularly useful when it's a matter of hosting pictures, CachedFirestorage ships with a built-in widget that you can use to display an image stored in your bucket.
Parameters (all named)
String imagePath
: The file path on your Firebase Storage bucketString mapKey
: The key at which your cached entry will be storedbool useAvatarView = false
: If true, it will render your image as an AvatarViewString? storageKey
: You can split the cache into sub-paths: this is the subpath keyString? placeholder
: The file path of a local asset to use as placeholderdouble? avatarViewRadius
: The radius of the avatar (mandatory ifuseAvatarView == true
)BoxFit? fit
: Optional parameter to be passed to a non-avatar image (ignored ifuseAvatarView == true
)