如何使用Flutter共享文件 [英] How to share a file using flutter
问题描述
我想知道如何在flutter应用程序中共享文件?
I am wondering how to share a file in a flutter app?
我看到了一些有关在Mojo中使用Intents的旧参考,但是似乎不再存在。这似乎是一项标准功能,我们应该能够以跨平台的方式进行处理(显然ios与android之间存在一些差异)。
I saw some old references to using Intents with mojo, but that no longer seems to be present. This seems like a standard feature that we should be able to handle in a cross-platform way (obviously with some differences between ios to android).
目前最好的功能是什么共享文件的方式(例如通过电子邮件)?我能找到的最接近的东西是UrlLauncher,我可以想象它用来为要共享的文件启动处理程序,但这似乎很麻烦。
What is the current best practices for sharing files (e.g. via email)? The closest thing I could fine is UrlLauncher, which I could imagine using to launch a handler for a file that I want shared, but it seems a stretch.
推荐答案
对于仍然发现此问题的任何人,您现在都可以使用共享插件共享一些内容: https://pub.dartlang.org/packages/share
For anybody still finding this question, you can now share something with the share plugin: https://pub.dartlang.org/packages/share
编辑:此插件仅支持文本/链接共享,不足以直接共享文件。问题 https://github.com/flutter/flutter/issues/16743 和 https://github.com/flutter/flutter/issues/19607 跟踪文件共享
This plugin only supports text/link share which is not sufficient for directly sharing files. The issues https://github.com/flutter/flutter/issues/16743 and https://github.com/flutter/flutter/issues/19607 track file sharing directly in flutter.
这篇关于如何使用Flutter共享文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!