【问题标题】:How to give multiple options for opening pdf,doc.pptx file in flutter?如何为在颤动中打开 pdf、doc.pptx 文件提供多个选项?
【发布时间】:2020-05-29 21:15:18
【问题描述】:

我想要解决这个问题----如果我点击 PDF、Doc、PPTX、Docx 文件,那么如何提供多个选项来打开该文件。 如何在 WPS office 等构建应用程序中在手机中打开该文件。

This is my code to show files in listview:

    ListView.builder(
                  scrollDirection: Axis.vertical,
                  shrinkWrap: true,
                  itemCount: attachments.length,
                  itemBuilder: (BuildContext ctxt, int index) {
                    print (index);
                    return ListView(
                        scrollDirection: Axis.vertical,
                        shrinkWrap: true,
                        children: <Widget>[
                          Padding(
                            padding: const EdgeInsets.all(1.0),
                            child: ListTile(
                              leading: CircleAvatar(
                                child: _getIcon(
                                    attachments[index].split('/').removeLast()),
                                backgroundColor: Colors.white,
                              ),
                              subtitle:
                              Text(attachments[index].split('/').removeLast()),
                              onTap: (){}
                            ),
                          ),
                        ]);
                  })

这是代码的输出:

现在点击文件如何在手机 WPS 办公应用中打开该文件。

【问题讨论】:

  • 显示一些代码并更好地解释您的问题
  • 我已经添加了我的代码

标签: flutter dart


【解决方案1】:

尝试使用https://pub.dev/packages/open_file。可调用原生APP打开带字符串结果flutter的文件,支持iOS(UTI)和android(intent)

【讨论】:

  • 实际上存储在另一台机器上的文件我想在我的手机中打开该文件。我有该文件的路径,即 String fileUrl = widget.schoolDcUrl + "/container" + attachments[index];
  • 我已经通过这个路径意味着 fileUrl 到 Open.file() 函数但是它的打开文件
  • 如果您将路径作为 http 的一部分,您可以在默认浏览器中打开它。让浏览器决定做什么
猜你喜欢
  • 2023-03-04
  • 2021-06-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-12
  • 2012-05-02
  • 1970-01-01
相关资源
最近更新 更多