搜尋套件、儲存庫與 APP 分類

套件詳情v1.4.0

flutter_share_me

用於將內容分享至社群媒體的 Flutter 插件。您可以使用它分享至 Facebook、WhatsApp、Twitter 及系統分享介面。支援 URL 與文字。

AndroidiOS
近 30 天下載
702
喜歡數
187
Pub 分數
120

安裝套件

flutter pub add flutter_share_me

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Flutter Share Me 是一個 Flutter 插件,可將文字和 URL 分享至 Facebook、WhatsApp 和 Twitter 等社交媒體平台,以及系統的原生分享介面。它透過最少的設定簡化跨平台分享,支援 Android 和 iOS。此外,該插件為開發者提供一致的 API,讓您能輕鬆整合分享功能,無需處理平台特定的程式碼。非常適合需要快速內容分享功能的應用。

適用情境

  • 在應用內分享連結
  • 發布文字更新到社交網絡
  • 整合系統共享對話框
  • 啟用使用者產生內容分享
  • 新增社交分享按鈕
  • 透過訊息應用推廣內容

主要特色

  • 支援 Facebook、WhatsApp、Twitter 和系統分享
  • 分享URL和純文字
  • 跨平台相容性(Android 與 iOS)
  • 簡單 API 結合
  • 無需平台特定程式碼
  • 內建的系統分享介面回退

適合對象

  • 社群媒體應用
  • 內容發布應用
  • 新聞或部落格應用
  • 具有產品分享功能的電子商務應用
  • 需要輕鬆使用者分享的應用程式

使用建議

  • Android 上需要正確的權限
  • 某些平台可能需要額外的設定
  • 限制為預定義的共享目標
  • 依賴外部應用程式之可用性
  • 不適合複雜的共用工作流程
  • 使用者必須安裝目標應用

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

flutter_share_me

pub package style: lint

Flutter Plugin for sharing contents to social media.

You can use it share to Facebook , Instagram , WhatsApp(WhatsAppBusiness) , Twitter, telegram And System Share UI. Support Url and Text.

support:

  • Android & iOS : Facebook,WhatsApp(WhatsAppBusiness),Twitter,Instagram,System Share

Note: This plugin is still under development, and some APIs might not be available yet.
Feedback and Pull Requests are most welcome!

Getting Started

add flutter_share_me as a dependency in your pubspec.yaml file.

Please check the latest version before installation.

dependencies:
  flutter:
    sdk: flutter
  # add flutter_share_me
  flutter_share_me: ^0.11.0

Setup

Android

Add "facebook app id" to the application tag of AndroidManifest.xml

    <application>
       ...
       //add this 
        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />
            
        <provider
            android:name="com.facebook.FacebookContentProvider"
            android:authorities="com.facebook.app.FacebookContentProvider[facebook_app_id]"
            android:exported="false" />
    </application>

string.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Replace "343254889799245" with your Facebook App ID here. -->
    <string name="facebook_app_id">343254889799245</string>
</resources>
IOS
setup facebook

make sure you add below deatils in your plist file.

<key>FacebookAppID</key>
<string>fbid</string>
<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>fb-your-fb-id</string>
			</array>
		</dict>
	</array>

Note-: Make sure you add fb in at start of your fb Id in CFBundleURLSchemes.

Add below value in url scheme(Refer to example).

	<array>
		<string>fbauth2</string>
		<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>fb-messenger-share-api</string>
		<string>fbauth2</string>
		<string>fbshareextension</string>
		<string>tg</string>
	</array>
Setup Whatsapp

Make sure you add whatsapp in plist.

        <array>
            <string>whatsapp</string>
        </array>
Setup Twiter
        <array>
            <string>twitter</string>
        </array>

Usage

Add the following imports to your Dart code:
import 'package:flutter_share_me/flutter_share_me.dart';

Methods

facebook
shareToFacebook({String msg, String url})
twitter
shareToTwitter({String msg, String url})
whatsapp
shareToWhatsApp({String msg,String imagePath})
shareToWhatsApp4Biz({String msg,String imagePath}) (only android)
shareWhatsAppPersonalMessage(String message ,String phoneNumber)
instagram
shareToInstagram({String filePath, FileType fileType})
telegram
shareToTelegram({String msg})
system
shareToSystem({String msg}) use system share ui

These methods will return "success" if they successfully jump to the corresponding app.

Parameter Description
String msg Text message
String url Url url
String imagePath The local path of the image

Example

 Container(
          width: double.infinity,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              SizedBox(height: 30),
              ElevatedButton(
                  onPressed: () => onButtonTap(Share.twitter),
                  child: Text('share to twitter')),
              ElevatedButton(
                onPressed: () => onButtonTap(Share.whatsapp),
                child: Text('share to WhatsApp'),
              ),
              ElevatedButton(
                onPressed: () => onButtonTap(Share.whatsapp_business),
                child: Text('share to WhatsApp  Business'),
              ),
              ElevatedButton(
                onPressed: () => onButtonTap(Share.facebook),
                child: Text('share to  FaceBook'),
              ),
              ElevatedButton(
                onPressed: () => onButtonTap(Share.share_system),
                child: Text('share to System'),
              ),
            ],
          ),
        )
Checkout the full example here

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案