Reputation: 2070
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 exception
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)
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,
),
),);
}
Upvotes: 3
Views: 5115
Reputation: 160
You can now use the Share plugin to do so!
ex:
Share.shareFiles(['${directory.path}/yourPdf.pdf'], text: 'Your PDF!');
Upvotes: 7