CachingResource class

Caches the members of resource on first access, to optimize subsequent accesses.

This can be useful when reading resource is expensive.

Warning: bytes are read and cached entirely the first time, even if only a range is requested. So this is not appropriate for large resources.

Inheritance

Constructors

CachingResource(Resource resource)

Properties

file File?
Direct file to this resource, when available.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
resource Resource
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

cached() Resource
Creates a cached resource wrapping this resource.
inherited
close() Future<void>
Closes any opened file handles.
override
length() Future<ResourceTry<int>>
Returns data length from metadata if available, or calculated from reading the bytes otherwise.
override
Returns the link from which the resource was retrieved.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read({IntRange? range}) Future<ResourceTry<ByteData>>
Reads the bytes at the given range.
override
readAsJson() Future<ResourceTry<Map<String, dynamic>>>
Reads the full content as a JSON object.
inherited
readAsString({String? charset}) Future<ResourceTry<String>>
Reads the full content as a String.
inherited
readAsXml() Future<ResourceTry<XmlDocument>>
Reads the full content as an XML document.
inherited
toString() String
A string representation of this object.
override
use<R>(Future<R> block(Resource resource)) Future<R>
Executes the given block function on this resource and then closes it down correctly whether an exception is thrown or not.
inherited

Operators

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