refactor, fix capacity handling

This commit is contained in:
mertalev
2026-01-21 02:46:21 -05:00
parent 9980d06f0c
commit cef5a7cf50
14 changed files with 68 additions and 77 deletions
@@ -16,13 +16,16 @@ class LocalImageRequest extends ImageRequest {
return null;
}
final Map<String, int> info = await localImageApi.requestImage(
final info = await localImageApi.requestImage(
localId,
requestId: requestId,
width: width,
height: height,
isVideo: assetType == AssetType.video,
);
if (info == null) {
return null;
}
final frame = await _fromDecodedPlatformImage(info["pointer"]!, info["width"]!, info["height"]!, info["rowBytes"]!);
return frame == null ? null : ImageInfo(image: frame.image, scale: scale);
@@ -12,8 +12,13 @@ class RemoteImageRequest extends ImageRequest {
return null;
}
final Map<String, int> info = await remoteImageApi.requestImage(uri, headers: headers, requestId: requestId);
final frame = await _fromEncodedPlatformImage(info["pointer"]!, info["length"]!);
final info = await remoteImageApi.requestImage(uri, headers: headers, requestId: requestId);
final frame = switch (info) {
{'pointer': int pointer, 'length': int length} => await _fromEncodedPlatformImage(pointer, length),
{'pointer': int pointer, 'width': int width, 'height': int height, 'rowBytes': int rowBytes} =>
await _fromDecodedPlatformImage(pointer, width, height, rowBytes),
_ => null,
};
return frame == null ? null : ImageInfo(image: frame.image, scale: scale);
}