繁体   English   中英

Flutter:如何将 PDF 文件共享到 Whatsapp 或 email 等内置应用程序

[英]Flutter: How to share PDF file to built inn apps like Whatsapp or email

我正在开发一个产品信息应用程序,我需要分享产品的规格 PDF,有什么办法吗? 我使用 package share_extend但是在使用它时出现异常

E/flutter (11283): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: MissingPluginException(No implementation found for method share on channel com.zt.shareextend/share_extend)
E/flutter (11283): #0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:314:7)

这是我的代码

Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        tooltip: 'Share File',
        onPressed: () async {


          var dir = await getApplicationDocumentsDirectory();
          File file = File('${dir.path}/${widget.product}.pdf');

          if (!await file.exists()) {
            await file.create(recursive: true);
            file.writeAsStringSync("test for share documents file");
          }

          ShareExtend.share(file.path, "file");


        },
        backgroundColor: Color(0xffECECEC),
        child: Icon(
          Icons.share,
          color: Color(0xff6F6F6F),
          size: 30.0,
        ),
      ),);
}

您现在可以使用Share 插件来做到这一点!

前任:

Share.shareFiles(['${directory.path}/yourPdf.pdf'], text: 'Your PDF!');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM