Hello everybody ! Today I am going to show you can take a screenshot of widgets and share it.


We are going to use RepaintBoundary to take the screenshot and esys_flutter_share to share this screenshot.

Let’s start

Firstly lets code the widget that we want to take screenshot of. Simply I’m going to make a Stack and put some Icons and Texts inside of it. You’ll use your own widget for it.

Our widget looks like :

Taking Screenshot

You should wrap your widget with RepaintBoundary and create a GlobalKey, RepaintBoundary takes the key.

Then create the _takeScreenShot() method ;

Only thing that we have to do is to create a button and give this method in onPressed.