I have a widget with an image and some information that I would like the user to be able to save and share as an image.
Does anyone know how to accomplish this without specifically telling the user to physically take the screenshot?
I have a widget with an image and some information that I would like the user to be able to save and share as an image.
Does anyone know how to accomplish this without specifically telling the user to physically take the screenshot?
I think this might be what you are looking for: https://docs.flutter.io/flutter/rendering/RenderRepaintBoundary/toImage.html
Basically you wrap your widget in a RepaintBoundary
. Supply the RepaintBoundary
with a key, which we can call boundaryKey
.
You can then do:
RenderRepaintBoundary boundary = boundaryKey.currentContext.findRenderObject();
and then do ui.Image image = await boundary.toImage();
to create an image that you can then use to create a png or whatever you want.