resolve method

ImageStream resolve (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 load, which are used by this method.


ImageStream resolve(ImageConfiguration configuration) {
  assert(configuration != null);
  final ImageStream stream = ImageStream();
  T obtainedKey;
  Future<void> handleError(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();
      exception: exception,
      stack: stack,
      context: 'while resolving an image',
      silent: true, // could be a network error or whatnot
      informationCollector: (StringBuffer information) {
        information.writeln('Image provider: $this');
        information.writeln('Image configuration: $configuration');
        if (obtainedKey != null) {
          information.writeln('Image key: $obtainedKey');
  obtainKey(configuration).then<void>((T key) {
    obtainedKey = key;
    final ImageStreamCompleter completer = PaintingBinding.instance.imageCache.putIfAbsent(key, () => load(key), onError: handleError);
    if (completer != null) {
  return stream;