debugDecodeGifForTest function

  1. @visibleForTesting
Future<({Codec codec, int naturalHeight, int naturalWidth})> debugDecodeGifForTest(
  1. Uint8List bytes, {
  2. BoxFit boxFit = BoxFit.none,
  3. int? preferredWidth,
  4. int? preferredHeight,
})

Implementation

@visibleForTesting
Future<({Codec codec, int naturalWidth, int naturalHeight})> debugDecodeGifForTest(
  Uint8List bytes, {
  BoxFit boxFit = BoxFit.none,
  int? preferredWidth,
  int? preferredHeight,
}) async {
  final ({int width, int height})? dims = BoxFitImage._tryParseGifDimensions(bytes);
  if (dims == null) {
    throw ArgumentError('Bytes are not a valid GIF (or missing header dimensions).');
  }
  final ({int? width, int? height}) targetSize = BoxFitImage._calculateTargetSize(
    naturalWidth: dims.width,
    naturalHeight: dims.height,
    boxFit: boxFit,
    preferredWidth: preferredWidth,
    preferredHeight: preferredHeight,
  );
  final Codec rawCodec = await instantiateImageCodec(
    bytes,
    targetWidth: targetSize.width,
    targetHeight: targetSize.height,
  );
  return (codec: _SafeImageCodec(rawCodec), naturalWidth: dims.width, naturalHeight: dims.height);
}