resolve method

  1. @nonVirtual
ImageStream resolve(
  1. ImageConfiguration configuration
)

Resolves this image provider using the given configuration, returning an ImageStream.

This is the public entry-point of the ImageProvider class hierarchy.

Subclasses should implement obtainKey and loadImage, which are used by this method. If they need to change the implementation of ImageStream used, they should override createStream. If they need to manage the actual resolution of the image, they should override resolveStreamForKey.

See the Lifecycle documentation on ImageProvider for more information.

Implementation

@nonVirtual
ImageStream resolve(ImageConfiguration configuration) {
  final ImageStream stream = createStream(configuration);
  // Load the key (potentially asynchronously), set up an error handling zone,
  // and call resolveStreamForKey.
  _createErrorHandlerAndKey(
    configuration,
    (T key, ImageErrorListener errorHandler) {
      resolveStreamForKey(configuration, stream, key, errorHandler);
    },
    (T? key, Object exception, StackTrace? stack) async {
      await null; // wait an event turn in case a listener has been added to the image stream.
      InformationCollector? collector;
      assert(() {
        collector = () => <DiagnosticsNode>[
          DiagnosticsProperty<ImageProvider>('Image provider', this),
          DiagnosticsProperty<ImageConfiguration>('Image configuration', configuration),
          DiagnosticsProperty<T>('Image key', key, defaultValue: null),
        ];
        return true;
      }());
      if (stream.completer == null) {
        stream.setCompleter(_ErrorImageCompleter());
      }
      stream.completer!.reportError(
        exception: exception,
        stack: stack,
        context: ErrorDescription('while resolving an image'),
        silent: true, // could be a network error or whatnot
        informationCollector: collector,
      );
    },
  );
  return stream;
}