toByteData method

Future<ByteData> toByteData ({ImageByteFormat format: ImageByteFormat.rawRgba })

Converts the Image object into a byte array.

The format argument specifies the format in which the bytes will be returned.

Returns a future that completes with the binary image data or an error if encoding fails.

Implementation

Future<ByteData> toByteData({ImageByteFormat format: ImageByteFormat.rawRgba}) {
  return _futurize((_Callback<ByteData> callback) {
    return _toByteData(format.index, (Uint8List encoded) {
      callback(encoded?.buffer?.asByteData());
    });
  });
}