问题
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