'How to create a screenshot taking application using Flutter?

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.



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jai Techie