MultiImageStreamCompleter constructor

MultiImageStreamCompleter({
  1. required Stream<Codec> codec,
  2. required double scale,
  3. Stream<ImageChunkEvent>? chunkEvents,
  4. InformationCollector? informationCollector,
})

The constructor to create an MultiImageStreamCompleter. The codec should be a stream with the images that should be shown. The chunkEvents should indicate the ImageChunkEvents of the first image to show.

Implementation

MultiImageStreamCompleter({
  required Stream<ui.Codec> codec,
  required double scale,
  Stream<ImageChunkEvent>? chunkEvents,
  InformationCollector? informationCollector,
})  : _informationCollector = informationCollector,
      _scale = scale {
  codec.listen(
    (event) {
      if (_timer != null) {
        _nextImageCodec = event;
      } else {
        _handleCodecReady(event);
      }
    },
    onError: (Object error, StackTrace stack) {
      reportError(
        context: ErrorDescription('resolving an image codec'),
        exception: error,
        stack: stack,
        informationCollector: informationCollector,
        silent: true,
      );
    },
  );
  if (chunkEvents != null) {
    _chunkSubscription = chunkEvents.listen(
      reportImageChunkEvent,
      onError: (Object error, StackTrace stack) {
        reportError(
          context: ErrorDescription('loading an image'),
          exception: error,
          stack: stack,
          informationCollector: informationCollector,
          silent: true,
        );
      },
    );
  }
}