NetworkResource<T> class

Network resources are fetched from the network and will cache a local copy.

The default strategy is to use CacheStrategy.networkFirst and fallback on cache when the network is unavailable.

Inheritance
Implementers

Constructors

NetworkResource({@required String url, @required LocalResource<T> cache, Duration maxAge, CacheStrategy strategy, Parser<T> parser})

Properties

cache LocalResource<T>
The local copy of the data fetched from url.
final
data → T
Synchronously get the most recently loaded data.
read-only, override
hashCode int
The hash code for this object. [...]
read-only, inherited
isExpired Future<bool>
Returns true if cache does not exist, false if it exists but maxAge is null; otherwise compares the cache's age to maxAge.
read-only
location String
The location (a path or url) of the resource.
final, inherited
maxAge Duration
Determines when the cache copy has expired and should be refetched.
final
parser Parser<T>
This parser will override the cache.parser.
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
strategy CacheStrategy
final
url String
The location of the data to fetch and cache.
read-only

Methods

fetchContents() Future
Fetch the raw contents from the underlying platform. [...]
inherited
get({bool forceReload: false, bool allowCacheFallback: true, bool skipCacheWrite: false}) Future<T>
Retrieve the data from RAM if possible, otherwise fallback to cache or network, depending on the strategy. [...]
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited