How to share a file using flutter

前端 未结 7 1278
悲哀的现实
悲哀的现实 2021-02-07 09:43

I am wondering how to share a file in a flutter app?

I saw some old references to using Intents with mojo, but that no longer seems to be present. This seems like a sta

7条回答
  •  迷失自我
    2021-02-07 10:16

    I used share_extend combine with path_provider to share an audio file and it works perfectly.

    void share() async {
    Directory dir = await getApplicationDocumentsDirectory();
    File testFile = new File("${dir.path}/sound.m4a");
    if (!await testFile.exists()) {
      await testFile.create(recursive: true);
      testFile.writeAsStringSync("test for share documents file");
    }
    ShareExtend.share(testFile.path, "file");
    

    }

提交回复
热议问题