getBytesFromAsset static method
Implementation
static Future<Uint8List?> getBytesFromAsset({
required String path,
required int height,
required int width,
}) async {
ByteData data = await rootBundle.load(path);
ui.Codec codec = await ui.instantiateImageCodec(
data.buffer.asUint8List(),
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();
}