getBytesFromUrl static method
Implementation
static Future<Uint8List?> getBytesFromUrl({required String url, required int height, required int width}) async {
final response = await http.get(Uri.parse(url));
ui.Codec codec = await ui.instantiateImageCodec(
response.bodyBytes,
targetHeight: height,
targetWidth: width,
);
ui.FrameInfo fi = await codec.getNextFrame();
final byteRes = await fi.image.toByteData(format: ui.ImageByteFormat.png);
if (byteRes == null) {
return null;
}
return byteRes.buffer.asUint8List();
}