Resource constructor
- dynamic uri, {
- ResourceLoader? loader,
Creates a resource object with the given uri
as location.
The uri
must be either a Uri or a String containing a valid URI.
If the string is not a valid URI, using any of the functions on
the resource object will fail.
The URI may be relative, in which case it will be resolved against Uri.base before being used.
The URI may use the package
scheme,
which is supported if the platform can load files at runtime at all.
Other schemes may also be supported where possible.
If loader
is provided, it is used to load absolute non-package URIs.
Package: URIs are resolved to a non-package URI before being loaded, so
the loader doesn't have to support package: URIs, nor does it need to
support relative URI references.
If loader
is omitted, a default implementation is used which supports
as many of http
, https
, file
and data
as are available on the
current platform.
Implementation
const Resource(uri, {ResourceLoader? loader})
: _uri = uri,
_loader = loader ?? const DefaultLoader();