我正在开发一个产品信息应用程序,我需要分享产品的规范 PDF,有什么办法吗?我使用包 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 plugin这样做!
例如:
Share.shareFiles(['${directory.path}/yourPdf.pdf'], text: 'Your PDF!');
关于file - Flutter:如何将 PDF 文件共享到 Whatsapp 或电子邮件等内置应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58884549/