toImageAsBytes method
Future<ByteData?>
toImageAsBytes({
- required int size,
- ImageByteFormat format = ui.ImageByteFormat.png,
- PrettyQrDecoration decoration = const PrettyQrDecoration(),
- 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);
}