Flutter: How to share PDF file to built inn apps like Whatsapp or email
3,063
You can now use the Share plugin to do so!
ex:
Share.shareFiles(['${directory.path}/yourPdf.pdf'], text: 'Your PDF!');
Author by
Alvin John Niravukalayil
Software engineer worked on ColdFusion, Java, JSP, Flutter, Android.
Updated on November 30, 2022Comments
-
Alvin John Niravukalayil over 1 year
I am developing an product information app, I need to share the spec PDF of the products, is there any way to do it. I use the package
share_extend
but while using this getting an exceptionE/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)
This is my code
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, ), ),); }
-
griffins over 4 yearsadd some code on how youre sharing the data
-
Alvin John Niravukalayil over 4 years@Ggriffo I had updated my code.
-
griffins over 4 yearsfound this issue from plugin repo github.com/zhouteng0217/ShareExtend/issues/14
-
griffins over 4 years[update] take away from issue chat flutter clean then get packages, upgrade packages,
-
Alvin John Niravukalayil over 4 yearsIt doesn't work, I removed it. Thanks for your reply.
-
-
btm me almost 2 yearsthis plugin discontinued now . anyother method for share pdf file ?