getImageDimensions method
Implementation
@override
Future<ImageDimensions> getImageDimensions(Uint8List imageBytes) async {
final blob = Blob([imageBytes]);
final imageUrl = Url.createObjectUrlFromBlob(blob);
final image = ImageElement();
image.src = imageUrl;
try {
// Wait for the image to load / render
await image.onLoad.first;
int? width = image.width;
int? height = image.height;
if (width == null || height == null) {
throw ("Width or height is null. Width: $width; Height: $height");
}
// Create the image dimensions object and return it
return ImageDimensions(width, height);
} catch (e) {
rethrow;
}
}