首页 > 解决方案 > 如何使用颤振截取其他应用程序的屏幕截图并上传到云存储

问题描述

请我一直在寻找一种从我的颤振应用程序中截取其他应用程序的方法。例如,如果我需要在不暂停游戏的情况下截取游戏应用程序并将其上传到云存储。颤振有可能吗?我所做的所有研究都显示了如何使用RepaintBoundary但我不想截取小部件的屏幕截图。任何帮助将不胜感激。

  FirebaseStorage storageReference = FirebaseStorage.instance;
  bool loading = false;
  final firestoreInstance = Firestore.instance;
  void convertWidgetToImage() async {
    RenderRepaintBoundary renderRepaintBoundary =
        _containerKey.currentContext.findRenderObject();
    ui.Image boxImage = await renderRepaintBoundary.toImage(pixelRatio: 1);
    ByteData byteData =
        await boxImage.toByteData(format: ui.ImageByteFormat.png);
    Uint8List uInt8List = byteData.buffer.asUint8List();
    this.setState(() {
      loading = true;
    });
    StorageUploadTask storageUploadTask = storageReference
        .ref()
        .child("${DateTime.now()}.png")
        .putData(uInt8List);
    await storageUploadTask;
    this.setState(() {
      loading = false;
    });
  }

标签: firebaseflutterscreenshot

解决方案


推荐阅读