How to implement a share button in Flutter app?

我与影子孤独终老i 提交于 2019-12-06 20:20:37

问题


In my app, I have a button and I need it to share Facebook when this button is clicked?


回答1:


Check out flutter share plugin

https://pub.dartlang.org/packages/share

Share.share('check out my website https://example.com');

Than use can choose to use facebook or any other service that supports share interface




回答2:


try this: https://github.com/d-silveira/flutter-share.git

if you want to share something other than text.

it allows sharing text/image/file with a simple named constructor instantiation Share.image(path: <PATH>, title: <TITLE>) and then call share() on it

just follow the instructions for further details on the README or see a working example in the example project folder.

It is fully functional for Android, the IOS part is currently being developed to match the Android part.




回答3:


You can try this package: https://pub.dev/packages/wc_flutter_share

This package supports sharing image + text both.

You can use this like:

await WcFlutterShare.share(  
    sharePopupTitle: 'share',  
    subject: 'This is subject',  
    text: 'This is text',  
    fileName: 'share.png',  
    mimeType: 'image/png',  
    bytesOfFile: bytes.buffer.asUint8List());

Note: On facebook you can't share image and text at the same time. You can either share text or image.




回答4:


This code is working fine:

await WcFlutterShare.share(  
    sharePopupTitle: 'share',  
    subject: 'This is subject',  
    text: 'This is text',  
    fileName: 'share.png',  
    mimeType: 'image/png',  
    bytesOfFile: bytes.buffer.asUint8List());


来源:https://stackoverflow.com/questions/50573933/how-to-implement-a-share-button-in-flutter-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!