getImageData method
Implementation
Future<Uint8List?> getImageData(ImageReference img) async {
final path = img.path;
if (hasCache(img)) return getCache(img);
if (img.bytes != null) {
setCache(img, img.bytes!);
return img.bytes;
}
if (path.startsWith('http')) {
final response = await client.get(Uri.parse(path));
if (response.statusCode == 200) {
final bytes = response.bodyBytes;
setCache(img, bytes);
return bytes;
}
}
if (path.startsWith('data:')) {
final base64 = path.split(',').last;
final bytes = base64Decode(base64);
setCache(img, bytes);
return bytes;
}
print('Failed to get image data: $path');
return null;
}