0 purchases
data cache manger
This package helps you to cache your data base on the expire time and also with diffrent kind of methods
Caching methods:
1-CacheOrAsynch
2-JustCache
3-JustAsync
Getting started #
For using this package you just to need add it to your pubspec.yaml file.
data_cache_manger :last version
After that import it where ever you want to use it.
import 'package:data_cache_manger/data_cache_manger.dart';
And finally like the blow codes use it to retrieve data from api or get data from storage.
Retrieved data cacheOrAsync
void cacheOrAsync() async {
// First it will check if the data exist in the storage retrieved data from there
// and if it does not exist there, then it retrieved them from async function
CacheManager<FaKeData> cacheManager = CacheManager<FaKeData>.cacheOrSync(
serializerFunc: (data) => Future.value(FaKeData.fromJson(data)),
key: 'your key',
asyncBloc: getFakeDataAsync);
FaKeData? faKeData = await cacheManager();
}
copied to clipboard
Retrieved data justAsync
void justAsync() async {
// it will just retrieve data async
CacheManager<FaKeData> cacheManager = CacheManager<FaKeData>.justAsync(
key: 'your key',
asyncBloc: getFakeDataAsync);
FaKeData? faKeData = await cacheManager();
print(faKeData.toString());
}
copied to clipboard
Retrieved data justAsync
void justCache() async {
// it will just retrieve data async
CacheManager<FaKeData> cacheManager = CacheManager<FaKeData>.justCache(
key: 'your key',
serializerFunc: (data) => Future.value(FaKeData.fromJson(data)),);
FaKeData? faKeData = await cacheManager();
print(faKeData.toString());
}
copied to clipboard
You can contribute on github https://github.com/mjdarvishi
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.