Tester12
Tester12

Reputation: 1011

How to screen record particular widget in flutter?

Currently, I'm using a flutter screen recorder plugin(https://pub.dev/packages/flutter_screen_recording) to record the screen, Actually, this plugin records the full screen of the mobile.

But my requirement is to record only a particular widget or a particular section of the screen, For example in the video call app there are two users in the screen, I just want to record only the opposite user video only.

So Is there any workaround or solution available for this, Please guide.

Upvotes: 8

Views: 9691

Answers (3)

Pushpendra Raja
Pushpendra Raja

Reputation: 1

screen recording function part not working its only save the gif but does not save the video

Upvotes: 0

Code on the Rocks
Code on the Rocks

Reputation: 17624

2021 Solution

There is a fairly new package called screen_recorder that can be used for exactly this.

Here's the example:

ScreenRecorder(
  height: 200,
  width: 200,
  background: Colors.white,
  controller: ScreenRecorderController(
    pixelRatio: 0.5,
    skipFramesBetweenCaptures: 2,
  ),
  child: // child which should be recorded
);

The only downsides are that it can't record platform views like the camera or a Google Maps widget and the recording must have a background color (so you can't record with a transparent background).

Upvotes: 3

meherdeep thakur
meherdeep thakur

Reputation: 873

I was facing a similar issue while taking screenshots as I was getting a blank or black screen while taking a screenshot. But then using this package solved that problem https://pub.dev/packages/native_screenshot

You can simply run this function to take the screenshot of your stream:

Future<void> _capturePng() async {
    String path = await NativeScreenshot.takeScreenshot();
    print(path);
  }

You can find the complete code here: https://github.com/Meherdeep/agora-videocall-demo

Upvotes: 0

Related Questions