Reputation: 1011
I'm currently using agora SDK for a flutter video call. During the video call, I need to take a screenshot. Only on the video call screen, the screenshot is black and on other screens the screenshots are fine. By using RenderRepaintBoundary I can't able to take a screenshot,
Code used to take the screenshot:
Future<void> _capturePng() async {
try {
RenderRepaintBoundary boundary =
_globalKey.currentContext.findRenderObject();
ui.Image image = await boundary.toImage(pixelRatio: 3.0);
ByteData byteData =
await image.toByteData(format: ui.ImageByteFormat.png);
var pngBytes = byteData.buffer.asUint8List();
final result = await ImageGallerySaver.saveImage(pngBytes);
} catch (e) {
print(e);
} } Widget build(BuildContext context) {
return RepaintBoundary(
key: _globalKey,
child: Scaffold(
backgroundColor: Colors.black,
body: GestureDetector(
onDoubleTap: () => _capturePng(),
child: Screenshot(
controller: screenshotController,
child: Center(
child: Stack(
children: <Widget>[
_viewRows(),
_toolbar(),
],
),
),
))));
}
issue screenshot:
working fine screenshot:
replace this below code with flutter main.dart sample
Agora rtc version:agora_rtc_engine: ^1.0.7
Also tried using this plugin: screenshot: ^0.1.1 but still, the issue occurs
Upvotes: 3
Views: 2027
Reputation: 244
I think your code for screenshoot is right. The problem may be in where you put the RepaintBoundary
. In general, the key
provided in RepaintBoundary
will be able to screenshot it's whole child hierarchy. So I think the solution is to put your Widget
which renders your live video feed inside RepaintBoundary
as child. e.g
Widget build(context){
return RepaintBoundary(
key: _yourGlobalKey,
child: _yourLiveVideoFeedWidget
);
}
Upvotes: 1
Reputation: 873
I believe there’s a problem with your screenshot method declaration, this is the syntax that needs to be followed:
ScreenshotController screenshotController = ScreenshotController();
Upvotes: 0