share_content_facebook 0.0.1+1 copy "share_content_facebook: ^0.0.1+1" to clipboard
share_content_facebook: ^0.0.1+1 copied to clipboard

Flutter Plugin for sharing contents to facebook.

share_content_facebook #

pub package Flutter Plugin for sharing contents to facebook.

Function IOS Android
shareContent OK OK
sharePhoto - OK

Getting Started #

add share_content_facebook

Please check the latest version before installation.

Install Plugin #

dependencies:
share_content_facebook: ^0.0.1

Setup Android #

  • Location add file strings.xml
    android/app/src/main/res/values/strings.xml
  • Edit strings.xml
    <resources>
   <string name="app_name">{APP_NAME}</string>
   // Replace "{APP_ID}" with your Facebook App ID here.
   <string name="facebook_app_id">{APP_ID}</string> 
   <string name="fb_login_protocol_scheme">fb{APP_ID}</string>
   </resources>
  • Edit location file "android/app/src/main/AndroidManifest.xml"
 <application>
 .
 ..
 ...
    <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
       <activity android:name="com.facebook.FacebookActivity" android:configChanges= "keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:label="@string/app_name" />
       <activity android:name="com.facebook.CustomTabActivity" android:exported="true">
           <intent-filter>
               <action android:name="android.intent.action.VIEW" />
               <category android:name="android.intent.category.DEFAULT" />
               <category android:name="android.intent.category.BROWSABLE" />
               <data android:scheme="@string/fb_login_protocol_scheme" />
           </intent-filter>
       </activity>
   <!-- Replace "{APP_ID}" with your Facebook App ID here. -->
            This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
       <provider android:authorities="com.facebook.app.FacebookContentProvider{APP_ID}"
           android:name="com.facebook.FacebookContentProvider"
           android:exported="true"/>
</application>

Setup IOS #

  • Edit location file "ios/Runner/Info.plist"
    <key>CFBundleURLTypes</key>
   <array>
     <dict>
       <key>CFBundleURLSchemes</key>
       <array>
         <string>fb{APP_ID}</string>
       </array>
     </dict>
   </array>
   <key>FacebookAppID</key>
   <string>{APP_ID}</string>
   <key>FacebookDisplayName</key>
   <string>{APP_NAME}</string>
   <key>LSApplicationQueriesSchemes</key>
   <array>
     <string>fbapi</string>
     <string>fbapi20130214</string>
     <string>fbapi20130410</string>
     <string>fbapi20130702</string>
     <string>fbapi20131010</string>
     <string>fbapi20131219</string>
     <string>fbapi20140410</string>
     <string>fbapi20140116</string>
     <string>fbapi20150313</string>
     <string>fbapi20150629</string>
     <string>fbapi20160328</string>
     <string>fbauth</string>
     <string>fbauth2</string>
     <string>fbshareextension</string>
   </array>

Methods #

shareContent({String url = "", String quote = "", String hashtag = ""})

sharePhoto({String pathImage = ""})

These methods will return "true/false" if they successfully jump to the corresponding app.

Parameter Description
String url Url url
String quote Explanation of "url"
String hashtag You can specify a single hashtag.

Example #

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: const Text('Plugin example app'),
          ),
          body: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Center(
                child: Text('Running on: $_platformVersion\n'),
              ),
              Center(
                child: RaisedButton(
                  onPressed: () async {
                  //sample shareContent
                    bool send = await ShareContentFacebook.shareContent(
                        url: "https://www.facebook.com",
                        quote: "Facebook",
                        hashTag: "#SHAREFACBOOK");
                    //sample sharePhoto
                    //bool send = await ShareContentFacebook.sharePhoto(pathImage: "images/logo.png");
                    print("send:$send");
                  },child: Text('Share Facebook'),),
              ),
            ],
          )
      ),
    );
  }
1
likes
20
pub points
0%
popularity

Publisher

unverified uploader

Flutter Plugin for sharing contents to facebook.

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on share_content_facebook