OneFrameImageStreamCompleter constructor

OneFrameImageStreamCompleter(
  1. Future<ImageInfo> image,
  2. {InformationCollector? informationCollector}
)

Creates a manager for one-frame ImageStreams.

The image resource awaits the given Future. When the future resolves, it notifies the ImageListeners that have been registered with addListener.

The InformationCollector, if provided, is invoked if the given Future resolves with an error, and can be used to supplement the reported error message (for example, giving the image's URL).

Errors are reported using FlutterError.reportError with the silent argument on FlutterErrorDetails set to true, meaning that by default the message is only dumped to the console in debug mode (see FlutterErrorDetails).

Implementation

OneFrameImageStreamCompleter(Future<ImageInfo> image, { InformationCollector? informationCollector }) {
  image.then<void>(setImage, onError: (Object error, StackTrace stack) {
    reportError(
      context: ErrorDescription('resolving a single-frame image stream'),
      exception: error,
      stack: stack,
      informationCollector: informationCollector,
      silent: true,
    );
  });
}