搜索插件、代码仓与 APP 分类

social_share 封面
插件详情v2.3.1

social_share

各种分享选项,满足您直接分享到某些知名应用的需求。

AndroidiOS
近 30 天下载
1810
喜欢数
409
Pub 分数
140

安装插件

flutter pub add social_share

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

social_share 包提供了一种简单高效的方法,可直接将内容分享到 Android 和 iOS 上的热门社交媒体应用。它支持广泛的分享选项,使用户能够快速将内容发布到 WhatsApp、Facebook、Instagram、Twitter 等平台。该包采用原生意图集成构建,确保在各种设备上实现无缝的分享体验。该包轻量且易于实现,非常适合需要强大分享功能但无需复杂设置的应用。

适合场景

  • 分享链接到社交媒体
  • 通过 WhatsApp 发送消息
  • 发布内容到Instagram
  • 与 Facebook 集成
  • 启用快速用户驱动分享
  • 支持跨平台共享

主要特点

  • 支持多个社交平台
  • 原生基于意图的共享
  • 简单 API 集成
  • 跨平台兼容性(Android 和 iOS)
  • 轻便且快速
  • 轻松配置

适合对象

  • 需要社交分享的移动应用
  • 面向广泛用户参与的应用程序
  • 寻求快速共享实现的开发者
  • 需要平台特定共享的项目
  • 包含用户生成内容分享的应用程序
  • 社交或社区驱动的应用

使用建议

  • 需要在 Android 上正确应用权限
  • 某些平台可能需要额外的设置
  • 仅限支持的社交应用
  • 依赖外部应用程序的可用性
  • 不适用于自定义共享目标
  • 平台特定的行为可能会有所不同

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

social_share

Wide variety of sharing options you'll need to share directly to certain popular apps or just share with default native share.

Introduction

Works on both platforms Android and iOS

It provides you with most of the popular sharing options With this plugin you can share on instagram stories and facebook stories and also copy to clipboard

Usage

Android Configuration
Paste the following attribute in the manifest tag in the android/app/src/main/AndroidManifest.xml:
 		`xmlns:tools="http://schemas.android.com/tools"`
For example:
        <manifest xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                package="your package...">
Add this piece of code in the manifest/application in the android/app/src/main/AndroidManifest.xml:
 		<provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.com.shekarmudaliyar.social_share"
            android:exported="false"
            android:grantUriPermissions="true"
            tools:replace="android:authorities">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/filepaths" />
        </provider>
Create a xml file named filepaths.xml in the app/src/main/res/xml folder and paste this code in the file :
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <cache-path name="image" path="/"/>
</paths>
iOS Configuration
Add this to your Info.plist to use share on instagram and facebook story
<key>LSApplicationQueriesSchemes</key>
	<array>
	<string>instagram-stories</string>
	<string>facebook-stories</string>
	<string>facebook</string>
	<string>instagram</string>
	<string>twitter</string>
	<string>whatsapp</string>
    <string>tg</string>
	</array>
Add this if you are using share on facebook. For this you have to create an app on https://developers.facebook.com/ and get the App ID
<key>FacebookAppID</key>
<string>xxxxxxxxxxxxxxx</string>
shareInstagramStory
SocialShare.shareInstagramStory(imageFile.path, "#ffffff",
                              "#000000", "https://deep-link-url");
shareInstagramStorywithBackground
 SocialShare.shareInstagramStorywithBackground(image.path, "https://deep-link-url",
                              backgroundImagePath: backgroundimage.path);
shareFacebookStory

For iOS

SocialShare.shareFacebookStory(image.path,"#ffffff","#000000",
                              "https://deep-link-url","facebook-app-id");

For Android appID is mandatory if using shareFacebookStory or else it wont work

SocialShare.shareFacebookStory(image.path,"#ffffff","#000000",
                              "https://deep-link-url","facebook-app-id",
							  appId: "xxxxxxxxxxxxx");
copyToClipboard
SocialShare.copyToClipboard("This is Social Share plugin");
shareTwitter
//without hashtags
SocialShare.shareTwitter("This is Social Share plugin");

//with hashtags
SocialShare.shareTwitter(
                              "This is Social Share twitter example",
                              hashtags: ["hello", "world", "foo", "bar"]);

//with hashtags and link
SocialShare.shareTwitter(
                              "This is Social Share twitter example",
                              hashtags: ["hello", "world", "foo", "bar"],url:"https://your-url-here/");
shareSms
//without url link in message
SocialShare.shareSms("This is Social Share Sms example");

//with url link in message
SocialShare.shareSms("This is Social Share Sms example",url: "https://your-url-here/");
shareWhatsapp
SocialShare.shareWhatsapp("Hello World");
shareTelegram
SocialShare.shareTelegram("Hello World");
shareOptions

This will open the default native share options

//without an image
SocialShare.shareOptions("Hello world");

//with an image
SocialShare.shareOptions("Hello world",imagePath: image.path);
checkInstalledAppsForShare
SocialShare.checkInstalledAppsForShare();

Here's few demo!

Story share on Instagram

insta story share demo

Story share on Facebook

fb story share demo

Copy to Clipboard

copy demo

Known issues

On Android 6, Share to Instagram Stories may not open Instagram app or load the specified image.

Buy me a :coffee: !!

((More coffee == more code) == faster updates)

Donate

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。