decodeImageData static method
Decodes image data represented as a Uint8List into a ui.Image asynchronously.
Parameters
- IN data A Uint8List representing the raw image data to be decoded.
- IN width Optional parameter specifying the desired width of the resulting image. Default value is 100.
- IN height Optional parameter specifying the desired height of the resulting image. Default value is 100.
Returns
The decoding process is asynchronous, so the returned Future will complete when the image decoding is finished.
Implementation
static Future<ui.Image?> decodeImageData(
final Uint8List data, {
final int width = 100,
final int height = 100,
}) async {
final Completer<ui.Image?> completer = Completer<ui.Image?>();
ui.decodeImageFromPixels(data, width, height, ui.PixelFormat.rgba8888, (
final ui.Image img,
) async {
completer.complete(img);
});
return completer.future;
}