hurshi / dio-http-cache

http cache lib for Flutter dio like RxCache
Apache License 2.0
274 stars 223 forks source link

can I use dio http cache with provider? #52

Open usernamekk opened 4 years ago

usernamekk commented 4 years ago
`Future<List<People>> getDataName() async {
    DioCacheManager _dioCacheManager;
  _dioCacheManager = DioCacheManager(CacheConfig());

  Options _cacheOptions =
  buildCacheOptions(Duration(days: 7), forceRefresh: true,);
  Dio _dio = Dio();
  _dio.interceptors.add(_dioCacheManager.interceptor);
  Response response = await _dio.get(
  'https://firebasestorage.googleapis.com/v0/b/sample-awka.appspot.com/o/people.json?alt=media',
  options: _cacheOptions);

   List<People> _persons =
       (response.data as List).map((pr) {
      print('$pr');

      People prt = People.fromJson(pr);
    }).toList();
return _persons;
}`

`Provider.of<People>(context).getDataName();`
ghenry commented 4 years ago

Does that work?

pishguy commented 4 years ago

Does that work?

it should be work, i'm using Provider and ProxyProvider