In Android, capturing WebView content works fine, but on iOS, it captures a blank screen. Is there a solution for this?
Code sample
/// UI
RepaintBoundary(
key: chartContainerKey,
child: Container(
color: Colors.transparent,
child: Center(
child: Column(
children: <Widget>[
SizedBox(
width: isPortrait ? (tabletLayout ? 400.h : 310.h) : (tabletLayout ? 800.h : 400.h),
height:
isPortrait ? (tabletLayout ? 430.h : 335.h) : (tabletLayout ? 310.h : 410.h),
child: Echarts(
key: ValueKey(DateTime.now()),
extensions: const [glScript],
captureAllGestures: true,
onLoad: (p0) {
print('로딩 완료');
// resizeChart();
},
option: '''
{
graphic: [
{
type: 'text',
z: 40,
top: '97%',
left: '4%',
....
....
/// capture
Future<bool> captureGraph() async {
try {
PermissionStatus ps = await Permission.photos.request();
if (ps.isPermanentlyDenied) {
noticeDialog(
context: context,
contents: "앱 설정에서 블루투스 권한을 허용해주세요.",
onPressed: () async {
await openAppSettings();
});
return false;
}
RenderRepaintBoundary boundary = chartContainerKey.currentContext!.findRenderObject() as RenderRepaintBoundary;
ui.Image image = await boundary.toImage(pixelRatio: 3.0);
ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List pngBytes = byteData!.buffer.asUint8List();
final result = await ImageGallerySaver.saveImage(Uint8List.fromList(pngBytes));
print(result);
return true;
} catch (e) {
print("Error capturing screen: $e");
return false;
}
}
Expected results
The capture includes the graph. (The results obtained on Android.)
enter image description here
Actual results
The capture is successful, but the graph appears as a white screen. (The results obtained on iOS.)
enter image description here
New contributor
이정아 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.