Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement a share button in Flutter app?

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

like image 818
asls2 Avatar asked May 28 '18 22:05

asls2


People also ask

How do you get share intents in Flutter?

You don't need your app to be running at all times to receive the data (through intent filter) and Flutter has nothing to do anything with it. Just open your AndroidManifest. xml file, add your intent-filter , there, its type and so on.


3 Answers

Check out flutter share plugin

https://pub.dev/packages/share_plus

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

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

like image 80
Tree Avatar answered Oct 20 '22 04:10

Tree


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.

like image 5
Ali Abbas Avatar answered Oct 20 '22 06:10

Ali Abbas


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.

like image 4
dsilveira Avatar answered Oct 20 '22 05:10

dsilveira