Skip to content

dmorillas/share_with_flutter

Repository files navigation

share_with_flutter

Flutter plugin to share content in Twitter and Facebook and get a callback when the action has taken place.

Android integration

  • Create your Facebook App and get your Facebook App ID. You can find it in your Facebook App's dashboard.

  • Open your /android/app/src/main/res/values/strings.xml file and add the following line:

    <string name="facebook_app_id">{FB_APP_ID}</string>
  • Add the following permission to your AndroidManifest.xml file:
    <uses-permission android:name="android.permission.INTERNET"/>
  • Add the following meta-data element to the application element:
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
  • Finally, you'll also need to add the following provider to the application element in your AndroidManifest.xml. Remember to substitute {APP_ID} by your actual AppId
<provider android:authorities="com.facebook.app.FacebookContentProvider{FB_APP_ID}"
          android:name="com.facebook.FacebookContentProvider"
          android:exported="true"/>

You can find an example of an AndroidManifest here.

Done!

iOS integration

  • Open your /ios/Runner/Info.plist file and add the following lines:
    <key>CFBundleURLTypes</key>
    <array>
      <dict>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>fb{FB_APP_ID}</string>
        </array>
      </dict>
    </array>
    <key>FacebookAppID</key>
    <string>{FB_APP_ID}</string>
    <key>FacebookDisplayName</key>
    <string>{YOUR_APP_NAME}</string>
    <key>LSApplicationQueriesSchemes</key>
    <array>
      <string>fbapi</string>
      <string>fb-messenger-share-api</string>
      <string>fbauth2</string>
      <string>fbshareextension</string>
    </array>

Done!

Usage

Add the following import to your code:

import 'package:share_with_flutter/share_with_flutter.dart';

Use the methods:

shareOnTwitter({String message = '', String link = '', String imagePath = ''})

Shares a tweet with the information passed. Returns when the share has been completed successfully with the result of it. Accepts the following parameters:

Parameter Description
String message Text message
String link The URL
String imagePath The local path of the file
shareOnFacebook({String link = '', String imagePath = ''})

shares a link or an image on Facebook. Returns when the share has been completed successfully with the result of it. Accepts the following arguments:

Parameter Description
String link The URL
String imagePath The local path of the file

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published