load method
The load method loads the image asynchronously and sets the image dimensions, viewport ratio, and raw image data.
Implementation
Future load(dynamic imageFile, Size viewportSize) async {
loader = Completer();
dynamic decodedImage;
if (imageFile is ImageItem) {
height = imageFile.height;
width = imageFile.width;
image = imageFile.image;
viewportRatio = imageFile.viewportRatio;
loader.complete(true);
} else if (imageFile is File || imageFile is XFile) {
image = await imageFile.readAsBytes();
decodedImage = await decodeImageFromList(image);
} else {
image = imageFile;
decodedImage = await decodeImageFromList(imageFile);
}
if (decodedImage != null) {
height = decodedImage.height;
width = decodedImage.width;
viewportRatio = viewportSize.height / height;
loader.complete(decodedImage);
}
return true;
}