takeScreenshot method
Captures the current rendered frame as a PNG data URL.
Returns null if the screenshot could not be taken.
Implementation
Future<String?> takeScreenshot() async {
if (_webViewController == null) return null;
try {
final result = await _webViewController!.runJavaScriptReturningResult(
"document.querySelector('model-viewer').toDataURL()");
return result.toString();
} catch (e) {
debugPrint('model_viewer_pro: takeScreenshot error — $e');
return null;
}
}