toImageAsBytes method

Future<ByteData?> toImageAsBytes({
  1. required int size,
  2. ImageByteFormat format = ui.ImageByteFormat.png,
  3. PrettyQrDecoration decoration = const PrettyQrDecoration(),
  4. ImageConfiguration configuration = ImageConfiguration.empty,
})

Returns the QR code image as a list of bytes.

Notes: Does not work with nested images on the Web until the stable Flutter 3.7.0 version. See: https://github.com/flutter/flutter/issues/103803.

Implementation

Future<ByteData?> toImageAsBytes({
  required final int size,
  final ui.ImageByteFormat format = ui.ImageByteFormat.png,
  final PrettyQrDecoration decoration = const PrettyQrDecoration(),
  final ImageConfiguration configuration = ImageConfiguration.empty,
}) async {
  final image = await toImage(
    size: size,
    decoration: decoration,
    configuration: configuration,
  );
  return image.toByteData(format: format);
}