fromUiImage static method

Future<Uint8List> fromUiImage(
  1. Image image
)

Converte um ui.Image em bytes PNG (Uint8List).

Implementation

static Future<Uint8List> fromUiImage(ui.Image image) async {
  final byteData = await image.toByteData(format: ui.ImageByteFormat.png);
  if (byteData == null) {
    throw Exception('Falha ao converter imagem para bytes');
  }
  return byteData.buffer.asUint8List();
}