resolve method

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

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 load, 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) {
  assert(configuration != null);
  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, dynamic exception, StackTrace stack) async {
      await null; // wait an event turn in case a listener has been added to the image stream.
      final _ErrorImageCompleter imageCompleter = _ErrorImageCompleter();
      stream.setCompleter(imageCompleter);
      InformationCollector collector;
      assert(() {
        collector = () sync* {
          yield DiagnosticsProperty<ImageProvider>('Image provider', this);
          yield DiagnosticsProperty<ImageConfiguration>('Image configuration', configuration);
          yield DiagnosticsProperty<T>('Image key', key, defaultValue: null);
        };
        return true;
      }());
      imageCompleter.setError(
        exception: exception,
        stack: stack,
        context: ErrorDescription('while resolving an image'),
        silent: true, // could be a network error or whatnot
        informationCollector: collector
        );
      },
    );
  return stream;
}