Alquama00s / cache

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cache

This flutter package lets you cache your api responses locally thus saving network calls

Installing

dependencies:
  flutter:
    sdk: flutter
  hive: ^2.0.5
  cache:
    git:
        url:https://github.com/Alquama00s/cache.git

Usage

A simple scenario includes your application fetching data from server (a get request) and then updating the modified change (A post request)

lets give this group of operations (get and post) on a particular data field a name say user-profile

just do the following to cache your user profile

const String userGroup = "user-profile";

String url = "my-url"; //no need to uri parse

Response r = cache.getRequest(url, cache:true, alias:userGroup); //this will automatically fetch ur data from local unless cache is expired then it will fetch it from server

cache.postRequest(url,headers,body, cache:true, alias:userGroup,); //this will invalidate the local cache so next time a get request will result in server call

About

License:Other


Languages

Language:Dart 100.0%