uriToUint8List static method
Future<Uint8List?>
uriToUint8List(
- UriData uri, {
- ImageByteFormat format = ui.ImageByteFormat.png,
Implementation
static Future<Uint8List?> uriToUint8List(UriData uri, {ui.ImageByteFormat format = ui.ImageByteFormat.png}) async
{
try
{
///////////////////////
/* Convert Uri Image */
///////////////////////
Uint8List bytesBase64 = uri.isBase64 ? uri.contentAsBytes() : Base64Codec().decode(uri.contentText);
ui.Codec codec = await ui.instantiateImageCodec(bytesBase64);
ui.FrameInfo frame = await codec.getNextFrame();
ByteData? data = await frame.image.toByteData(format: format );
return data?.buffer.asUint8List();
}
catch(e)
{
Log().exception(e);
}
return null;
}