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 retrvied data from api or get data from storage.
Retrieved data cacheOrAsync And finally like the blow code use it to get data from api or get data from storage.

 void test() async {
  CacheManager _cacheManager = CacheManager(StorageImplimentation());
  final apiProvider = AuthRepository(http);

  await _cacheManager
      .from<Login>("")
      .withSerializer((result) {})
      .withAsync(() => apiProvider.sendCode(''))
      .withStrategy(CacheOrAsyncStrategy())
      .execute();
}

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