Flutter 如何在颤振应用程序中打开pdf、pptx、doc、docx文件?

Flutter 如何在颤振应用程序中打开pdf、pptx、doc、docx文件?,flutter,dart,Flutter,Dart,如果我点击文件如何打开颤振应用程序内的文件。 这就是我所做的: onTap: () async { String fileUrl = widget.schoolDcUrl + "/container"attachments[index]; final _openFile = await OpenFile.open(fileUrl); Logger.i(_openFile);

如果我点击文件如何打开颤振应用程序内的文件。 这就是我所做的:

            onTap: () async {
            String fileUrl = widget.schoolDcUrl + "/container"attachments[index];
            final _openFile = await OpenFile.open(fileUrl);
             Logger.i(_openFile);
                              }

此代码用于在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: (){}
                        ),
                      ),
                    ]);
              })
当我点击文件时,它不会打开文件,它会给出一条关于终端文件未找到的消息


我希望onTap在应用程序中打开该文件。

您应该能够使用打开所有这些文件格式的软件包


确保遵循自述文件上的配置和示例。

无需下载文件,您可以使用以下软件包从URL打开:


publispec.yaml
中添加:

dev_dependencies:
   open_file: ^3.0.1
在代码中添加:

import 'package:open_file/open_file.dart';

OpenFile.open("/sdcard/example.pptx");

打开文件
文档:

在应用程序中打开文件需要大量代码才能处理所有格式,强烈建议使用专用应用程序,您可以使用:我使用了Open_文件包,但它不起作用——这是我在应用程序上完成的代码:()异步{String fileUrl=widget.schoolDcUrl+“/container”+附件[index];字符串fileUrl1=Uri.encodeFull(fileUrl);final _openFile=wait openFile.open(fileUrl);Logger.i(_openFile);}我的文件来自api---字符串fileUrl=widget.schoolDcUrl+“/container”附件[index];这是我的文件url:String fileUrl=widget.schoolDcUrl+“/container”attachments[index];现在我点击文件如何打开内部颤振应用程序你是否尝试使用我在回答中链接的软件包?这些文件是本地的还是远程的?
import 'package:open_file/open_file.dart';

OpenFile.open("/sdcard/example.pptx");