How to create a screenshot taking application using Flutter?

Viewed 1593

I am thinking of making a Screenshot application using Flutter.

The features of the screenshot application will be:

  • Creating a floating button, that can float/draw over other apps. The button is should be draggable too.
  • Taking screenshot of the whole screen, when the user presses the floating button.
  • Storing the screenshots in the local storage.

Like this floating button. And when I click that floating button, it should take a screenshot of the whole screen.

Is there any widget or package available for this purpose? Any suggestions for implementing this approach are welcome.

Thank you.

1 Answers

There is an plugin (screenshot) which allows you to capture widgets as Images. So you can also capture the widgets that are not rendered on the screen.

Step 1:

  //Create an instance of ScreenshotController
  ScreenshotController screenshotController = ScreenshotController();

Step 2: Wrap the widget that you want to capture inside Screenshot

Screenshot(
    controller: screenshotController,
    child: Text("This text will be captured as image"),
),

Step 3: Take the screenshot by calling capture method. This will return a Uint8List

screenshotController.capture().then((Uint8List image) {
    //Capture Done
    setState(() {
        _imageFile = image;
    });
}).catchError((onError) {
    print(onError);
});

Hence, if you wanna save the image to specific location and share use captureAndSave method by passing directory location.

Related