Printar or draw widget with flutter

Asked

Viewed 278 times

0

I have the following dialog and would like to generate a "voucher" so that the person could share it, as if it were proof of payments that the bank applications generate. dialog para gerar comprovante

I managed to take a "print" using Renderrepaintbundary, with the code below, but it gets a horrible resolution and with the texts very disproportionate.

RenderRepaintBoundary boundary = globalKey.currentContext.findRenderObject(); 
  var image = await boundary.toImage(pixelRatio: 5.0);
  ByteData byteData = await image.toByteData(format: ImageByteFormat.png);
  Uint8List pngBytes = byteData.buffer.asUint8List();       
  final tempDir = await getTemporaryDirectory();
  final file = await new File('${tempDir.path}/image.png').create();
  await file.writeAsBytes(pngBytes);
  final ByteData bytes = await rootBundle.load(file.path);
  await Share.file('Invite', 'qrcode.png', bytes.buffer.asUint8List(), 'image/png', text: 'Convite para entrada no meu condomínio'); 

1 answer

0

Blz? it has been a while since the question, but I believe the answer is valid in the future

just add the parameter pixelRatio in the Library.image

Future<void> _capturePng() async {
RenderRepaintBoundary boundary =
    _globalKey.currentContext.findRenderObject();
ui.Image image = await boundary.toImage(pixelRatio: 3.0);
ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List pngBytes = byteData.buffer.asUint8List();

await Share.file('ESYS AMLOG', 'amlog.jpg', pngBytes, 'image/jpg');}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.