network_resource library

Automatically cache network resources and use them when offline.

NetworkResource<T> fetches data over HTTP, caches it in a file, and holds it in memory. The main method, NetworkResource.get(), will return the value in memory, cache, or fetch from the network -- in that order. If the cache file is older than NetworkResource.maxAge, the cache will be updated from the network if available. To manually refresh, use get(forceReload: true) or NetworkResource.getFromNetwork(). The latter can be used to avoid cache fallback.

Classes

BinaryNetworkResource
A class to fetch List<int> data from the network (bytes), cache it in a file, and hold it in memory.
NetworkResource<T>
A base implementation to fetch data over HTTP, cache it in a file, and hold it in memory. [...]
StringListNetworkResource
A class to fetch List<String> data from the network, cache it in a file, and hold it in memory.
StringNetworkResource
A class to fetch String data from the network, cache it in a file, and hold it in memory.