Open
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
I am getting error while trying to get screenshot of inappwebview on some devices. I didn't get any error on my devices.
Expected Behavior
Working perfectly.
Steps with code example to reproduce
Steps with code example to reproduce
I am trying to get screenshot of my app. I am trying to do with screenshot plugin, but webview content is not showing that screenshot. So I 'm getting screenshot of inappwebview and combine them. When following code triggerred error happens: Future<void> captureAndShare() async {
Uint8List? webScreenshot = await webViewController?.takeScreenshot();
if (webScreenshot == null) {
print("WebView screenshot failed.");
return;
}
Uint8List? flutterScreenshot = await screenshotController.capture();
if (flutterScreenshot == null) {
print("Flutter widget screenshot failed.");
return;
}
img.Image webImg = img.decodeImage(webScreenshot)!;
img.Image flutterImg = img.decodeImage(flutterScreenshot)!;
int offsetX = (flutterImg.width - webImg.width) ~/ 2;
int offsetY = (flutterImg.height - webImg.height) ~/ 2 - (flutterImg.height ~/ 10);
img.Image combinedImage = img.Image(width: flutterImg.width, height: flutterImg.height);
combinedImage = img.compositeImage(
combinedImage,
flutterImg,
dstX: 0,
dstY: 0,
);
combinedImage = img.compositeImage(
combinedImage,
webImg,
dstX: offsetX,
dstY: offsetY,
);
Uint8List finalImageBytes = Uint8List.fromList(img.encodePng(combinedImage));
final tempDir = await getTemporaryDirectory();
final file = File('${tempDir.path}/screenshot.png');
await file.writeAsBytes(finalImageBytes);
Share.shareXFiles([XFile(file.path)], text: promoteText);
}
This code is using for getting screenshot.png by using screenshot plugin and webViewController?.takeScreenshot() method then combine them and share. Exception happened in this line:
Uint8List? webScreenshot = await webViewController?.takeScreenshot();
Stacktrace/Logs
Stacktrace/Logs
Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError
MissingPluginException(No implementation found for method takeScreenshot on channel com.pichillilorenzo/flutter_inappwebview_4)
Fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: MissingPluginException(No implementation found for method takeScreenshot on channel com.pichillilorenzo/flutter_inappwebview_4)
at MethodChannel._invokeMethod(platform_channel.dart:368)
at AndroidInAppWebViewController.takeScreenshot(in_app_webview_controller.dart:2013)
at MyCodeState.captureAndShare(my_code.dart:117)
Flutter version
v3.29.0
Operating System, Device-specific and/or Tool
Android
Plugin version
v6.1.5
Additional information
Self grab
- I'm ready to work on this issue!