[英]how to take screenshot with a flutter app while it is in the background
我正在嘗試制作一個flutter 應用程序,該應用程序在后台運行時截取屏幕截圖,當我將來自firebase的通知推送到應用程序時,有人可以幫我解決這個問題嗎? 或至少教程的一些鏈接(只有在應用程序收到通知時才應觸發屏幕截圖)因為我是編程新手,對此我不太了解。謝謝
使用 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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.