FunctionProtocolResolver class final
A ProtocolResolver made from a function, for a resolver too small to deserve a class.
// One fixed location served from memory.
final loader = DefaultResourceLoader(
protocolResolvers: [
FunctionProtocolResolver(
(location, _) => location == 'inline:greeting'
? ByteArrayResource.fromString('hello=world')
: null,
),
],
);
Spring (Java):
// ProtocolResolver is a functional interface, so a lambda is enough:
loader.addProtocolResolver((location, resourceLoader) ->
location.equals("inline:greeting")
? new ByteArrayResource("hello=world".getBytes())
: null);
- Implemented types
Constructors
- FunctionProtocolResolver(Resource? _resolve(String location, ResourceLoader resourceLoader))
-
Creates a resolver that calls the given function, which returns
nullfor locations it does not handle.const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolve(
String location, ResourceLoader resourceLoader) → Resource? -
The resource for
location, ornullwhen this resolver does not handle it, so the next resolver (or the built-in rules) is tried.resourceLoaderis the loader asking, for resolvers that delegate.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited