6

Some comments on this answer suggest that it is possible to capture every pixel of a widget, even if it is partially offscreen. Comments in this answer suggest the opposite. I haven't been able to figure it out, I've only started messing with it today. Here's the code I have so far:

RenderRepaintBoundary boundary = globalKey.currentContext.findRenderObject();
ui.Image image = await boundary.toImage();
ByteData byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List pngBytes = byteData.buffer.asUint8List();

Anyone know how to modify this so it will capture the full widget? Or does this only work with the portions of the widget that are on-screen?

FWIW, the answer provided in a similar question marking this one as duplicate is self-described as intentionally breaking things that flutter does for optimization, and only in worst-case scenario. I'm looking for an answer that doesn't have to do crazy stuff that will break in 2 years.

A. L. Strine
  • 611
  • 1
  • 7
  • 23

0 Answers0