gpt4 book ai didi

python - 如何在后台运行时使用flutter应用程序截屏

转载 作者:行者123 更新时间:2023-12-03 03:51:10 25 4
gpt4 key购买 nike

我正在尝试制作一个 flutter 应用程序,它在背景中运行时需要屏幕截图,而当我将 firebase 的通知推送到该应用程序时,有人可以帮我解决这个问题吗?或至少教程的某些链接(仅当应用程序收到通知时,才应触发屏幕截图)
我曾尝试到处搜寻,也遇到媒体投影,但这仅适用于android studio
如果有人帮我解决这个问题,那真是太好了,因为我是编程新手,对此我不太了解。谢谢

最佳答案

使用RenderRepaintBoundary

var repaintScreen = new GlobalKey();
//您要为其截屏或说要捕获图像的部分
RepaintBoundary(
key: repaintScreen,
child: Container(
)
),

RenderRepaintBoundary boundary =
repaintScreen.currentContext.findRenderObject();

prefix0.Image image = await boundary.toImage();
final directory = (await getApplicationDocumentsDirectory()).path;
ByteData byteData =
await image.toByteData(format: prefix0.ImageByteFormat.png);
Uint8List pngBytes = byteData.buffer.asUint8List();
print(pngBytes);
File imgFile = new File('$directory/poct.jpeg');
imgFile.writeAsBytes(pngBytes);

关于python - 如何在后台运行时使用flutter应用程序截屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63393214/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com