loadImage static method
Future<Image?>
loadImage(
- dynamic url,
- dynamic flipY, {
- Function? imageDecoder,
})
Implementation
static Future<Image?> loadImage(url, flipY, {Function? imageDecoder}) async {
Image? image;
if (imageDecoder == null) {
Uint8List? bytes;
if (url is Blob) {
bytes = url.data;
} else if (url.startsWith("http")) {
var response = await http.get(Uri.parse(url));
bytes = response.bodyBytes;
} else if (url.startsWith("assets")) {
final fileData = await rootBundle.load(url);
bytes = Uint8List.view(fileData.buffer);
} else {
var file = File(url);
bytes = await file.readAsBytes();
}
image = await compute(imageProcess2, DecodeParam(bytes!, flipY, null));
} else {
image = await imageDecoder(null, url);
}
return image;
}