debugDecodeGifForTest function
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);
}