Last updated:
0 purchases
flutter share social
flutter_share_social #
Share to Facebook and Zalo (coming soon) Flutter plugin.
Getting Started #
To get things up and running, you'll have to declare a pubspec dependency in your Flutter project.
Also some minimal Android & iOS specific configuration must be done, otherise your app will crash.
On your Flutter project #
flutter_share_social:
flutter_share_social: ^0.2.1
Android #
In addition, you need to do the following:
Get a Facebook App ID properly configured and linked to your Android app. See Android Getting Started, Add Facebook App ID.
Generate an Android Key Hash and add it to your developer profile
Add a Facebook Activity and include it in your AndroidManifest.xml
For details on these requirements, see Android - Getting Started.
After you've done that, find out what your Facebook App ID is. You can find your Facebook App ID in your Facebook App's dashboard in the Facebook developer console.
Once you have the Facebook App ID figured out, you'll have to do two things.
First, copy-paste the following to your strings resource file. If you don't have one, just create it.
<your project root>/android/app/src/main/res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Your App Name here.</string>
<!-- Replace "000000000000" with your Facebook App ID here. -->
<string name="facebook_app_id">000000000000</string>
</resources>
copied to clipboard
Then you'll just have to copy-paste the following to your Android Manifest and replace 000000000000000 with your Facebook App ID and you also need to set up a ContentProvider in your AndroidManifest.xml where {APP_ID} is your app ID:
<your project root>/android/app/src/main/AndroidManifest.xml
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
<meta-data android:name="com.facebook.sdk.ApplicationName"
android:value="@string/app_name"/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<provider android:authorities="com.facebook.app.FacebookContentProvider{FACEBOOK_APP_ID}"
android:name="com.facebook.FacebookContentProvider"
android:exported="true"/>
<provider android:name="androidx.core.content.FileProvider"
android:authorities="{APP_PACKAGE}.social.share.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
copied to clipboard
Done!
iOS #
Before you add sharing to your app you need to:
Add the Facebook SDK for iOS to your mobile development environment
Configure and link your Facebook app ID
Add your app ID, display name, and human-readable reason for photo access to your app's .plist file.
After you've done that, find out what your Facebook App ID is. You can find your Facebook App ID in your Facebook App's dashboard in the Facebook developer console.
Once you have the Facebook App ID figured out, then you'll just have to copy-paste the following to your Info.plist file, before the ending </dict></plist> tags.
<your project root>/ios/Runner/Info.plist
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<!--
Replace "000000000000" with your Facebook App ID here.
**NOTE**: The scheme needs to start with `fb` and then your ID.
-->
<string>fb000000000000</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<!-- Replace "000000000000" with your Facebook App ID here. -->
<string>000000000000</string>
<key>FacebookDisplayName</key>
<!-- Replace "YOUR_APP_NAME" with your Facebook App name. -->
<string>YOUR_APP_NAME</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>instagram</string>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
copied to clipboard
Done!
How do I use it? #
Instagram #
import 'package:flutter_share_social/flutter_share_social.dart';
File file = await ImagePicker.pickImage(source: ImageSource.gallery);
await FlutterShareSocial.instagramShare(path: file.path);
copied to clipboard
Facebook #
import 'package:flutter_share_social/flutter_share_social.dart';
File file = await ImagePicker.pickImage(source: ImageSource.gallery);
await FlutterShareSocial.facebookShare(path: file.path);
await FlutterShareSocial.facebookSharePhotos(paths: List<file.path>);
await FlutterShareSocial.facebookShareLink(quote: 'quote', url: 'https://flutter.dev');
copied to clipboard
That's it.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.