HttpNetworkResource<T> class

A NetworkResource over HTTP.

Inheritance

Constructors

HttpNetworkResource({@required String url, @required LocalResource<T> cache, Duration maxAge, CacheStrategy strategy, Parser parser, Client client, Map<String, String> headers, bool binary: false, List<int> acceptedResponses: const [200]})

Properties

acceptedResponses List<int>
Acceptable HTTP response codes. The response body will only be returned if the status code matches one of these.
final
binary bool
Whether the underlying data is binary or string-based.
final
cache LocalResource<T>
The local copy of the data fetched from url.
final, inherited
client Client
Optional. The http.Client to use, recommended if frequently hitting the same server. If not specified, http.get() will be used instead.
final
data → T
Synchronously get the most recently loaded data.
read-only, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
headers Map<String, String>
Optional. The HTTP headers to send with the request.
final
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, inherited
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, inherited
parser Parser<T>
This parser will override the cache.parser.
final, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
strategy CacheStrategy
final, inherited
url String
The location of the data to fetch and cache.
read-only, inherited

Methods

fetchContents() Future
Fetch the raw contents from the underlying platform. [...]
override
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. [...]
inherited
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