asset_downloader 1.0.0 asset_downloader: ^1.0.0 copied to clipboard
The flutter library designed for efficiently downloading, saving, and utilizing various types of files/assets in a widget.
Asset Downloader #
Overview #
The AssetDownloader is a Flutter plugin designed for efficiently downloading, saving, and utilizing various types of files/assets in a widget.
How to Use #
Before utilizing the AssetDownloader plugin, make sure to initialize it by calling:
await AssetDownloader.initialize();
After initialization, you can use the CachedAssetWidget
as follows:
CachedAssetWidget(
url: 'https://example.com/image.png',
/// fileName parameter is optional but can be useful if the file extension is needed
fileName: 'abc.jpg',
builder: (context, file) {
return Image.file(file);
},
placeholder: (context) {
return CircularProgressIndicator();
},
);
Key Features #
Ready to Use #
The AssetDownloader includes a CachedAssetWidget
, making it straightforward to integrate by simply passing the URL of the desired file.
Manual Pre-Downloads #
Enables manual queuing of pre-downloads, allowing the application to fetch assets in advance for future use.
Use the enqueueDownloadTask
method exposed by the AssetDownloader.
Auto-Deletion of Unused Files #
To prevent unnecessary storage clutter, the plugin includes a cleanup mechanism that automatically deletes unused files.
Configurable Stale Period and Capacity #
During initialization, users can specify the total allowed stale period. If a file remains untouched for this duration, it is flagged for deletion during the cleanup process.
The configuration also includes setting the total capacity, defining the total number of downloads allowed. If there are more downloaded files than the specified capacity, the least recently used files will be removed.