resolve method
PictureStream
resolve(
- PictureConfiguration picture, {
- PictureErrorListener? onError,
inherited
Resolves this Picture provider using the given configuration
, returning
an PictureStream
.
This is the public entry-point of the PictureProvider
class hierarchy.
Subclasses should implement obtainKey
and load
, which are used by this
method.
Implementation
PictureStream resolve(PictureConfiguration picture,
{PictureErrorListener? onError}) {
// ignore: unnecessary_null_comparison
assert(picture != null);
final PictureStream stream = PictureStream();
obtainKey(picture).then<void>(
(T key) {
_lastKey = key;
stream.setCompleter(
cache.putIfAbsent(
key!,
() => load(key, onError: onError),
),
);
},
).catchError((Object exception, StackTrace stack) async {
if (onError != null) {
onError(exception, stack);
return;
}
FlutterError.reportError(FlutterErrorDetails(
exception: exception,
stack: stack,
library: 'SVG',
context: ErrorDescription('while resolving a picture'),
silent: true, // could be a network error or whatnot
informationCollector: () => <DiagnosticsNode>[
DiagnosticsProperty<PictureProvider>('Picture provider', this),
DiagnosticsProperty<T>('Picture key', _lastKey, defaultValue: null),
],
));
});
return stream;
}