data_cache_manger 0.0.2 copy "data_cache_manger: ^0.0.2" to clipboard
data_cache_manger: ^0.0.2 copied to clipboard

useful package to manage data caching

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();

}

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());
}

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());
}

You can contribute on github https://github.com/mjdarvishi

0
likes
110
points
34
downloads

Publisher

unverified uploader

Weekly Downloads

useful package to manage data caching

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, hive, hive_flutter

More

Packages that depend on data_cache_manger