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

share_social_network 封面
插件详情v1.2.9

share_social_network

一个现成的平台,提供多种分享方式,您需要直接为某些流行的应用程序提供访问权限,或者仅使用内置的默认分享功能进行分享。

AndroidiOS
近 30 天下载
16
喜欢数
26
Pub 分数
105

安装插件

flutter pub add share_social_network

插件介绍

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

share_social_network 包提供了一种简单的方法,将分享功能集成到 Flutter 应用中,使用户能够跨主流社交平台分享内容,或使用系统的默认分享选项。它简化了在 Android 和 iOS 上访问原生分享意图的过程,减少了样板代码。开发者可以轻松触发分享,配置极少,支持直接应用特定的分享和通用系统级别的分享。该包非常适合需要快速、可靠分享功能而无需复杂设置的应用。

适合场景

  • 在社交媒体应用内分享链接或文本
  • 启用用户生成内容分发
  • 集成默认系统共享对话框
  • 支持跨平台共享工作流程
  • 在应用界面中添加分享按钮

主要特点

  • 与 Flutter 的简单集成
  • 对 Android 和 iOS 的支持
  • 直接访问热门社交应用
  • 回退到系统默认共享
  • 最小配置要求

适合对象

  • 需要基本共享功能的应用
  • 寻求快速共享实现的开发者
  • 跨平台移动应用
  • 社交媒体集成
  • 内容共享平台

使用建议

  • 共享界面的自定义功能有限
  • 取决于设备上安装的社交应用
  • 分享无内置分析功能
  • 某些平台需要适当的权限
  • 可能不支持所有小众社交网络

原始 README

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

Share Social Network

pub package

A ready-made platform that provides a wide range of ways to share, you will need to provide access directly to certain popular applications or just share using the built-in default sharing.

Platforms

Works on both platforms Android and iOS

Image Image Image
Video Photo Video

Initial settings

Android Configuration
Paste the following attribute in the AndroidManifest.xml 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...
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>
Add this code snippet to the very bottom manifest/application in the android/app/src/main/AndroidManifest.xml insert after meta-data:
 		     <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.com.weeidl.share_social_network"
            android:exported="false"
            android:grantUriPermissions="true"
            tools:replace="android:authorities">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/filepaths" />
        </provider>
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>

Getting Started

Add the package to your pubspec.yaml:

   share_social_network: ^1.2.9

In your dart file, import the library:

    import 'package:share_social_network/share_social_network.dart';

Instead of using a ShareSocialNetwork use ShareSocialNetwork.show Widget:

  ShareSocialNetwork.show(
    context: context,
    backgroundColor: Colors.white,
    pillColor: Colors.black12,
    transitionDuration: Duration(milliseconds: 300),
    screenshotController: screenshotController,
    copyToClipboard: "https://github.com/weeidl/share_social...",
    telegram: Telegram(
      content: "Hello World \n https://github.com/weeidl",
    ),
    instagram: Instagram(
      backgroundBottomColor: "#FF7391",
      backgroundTopColor: "#591E78",
      attributionURL: "https://deep-link-url",
      imagePath: imagePath,
    ),
    facebook: Facebook(
      backgroundTopColor: "#ffffff",
      attributionURL: "https://github.com/weeidl",
      backgroundBottomColor: "#000000",
      imagePath: imagePath,
      appId: "xxxxxxxxxxxxx",
    ),
    more: More(
      message: 'Hello World \n https://github.com/weeidl',
    ),
    twitter: Twitter(
      captionText: 'Share twitter',
      hashtags: ["hello", "world", "weeild", "artur"],
      url: 'https://github.com/weeidl',
      trailingText: " \nweeidl",
    ),
    whatsapp: Whatsapp(
      content: 'Hello World \n https://github.com/weeidl',
    ),
  );
 }
Example:

Example of how to send something to instagram:

ScreenshotController screenshotController = ScreenshotController();
void shareSocialNetwork(BuildContext context) async {
  String imagePath = await screenshotController.capture().then((image) async {
    final directory = await getApplicationDocumentsDirectory();
    final file = await File('${directory.path}/temp.png').create();
    await file.writeAsBytes(image!);
    return file.path;
  });
  ShareSocialNetwork.show(
    context: context,
    backgroundColor: Colors.white,
    pillColor: Colors.black12,
    transitionDuration: Duration(milliseconds: 300),
    screenshotController: screenshotController,
    copyToClipboard: "https://github.com/weeidl/share_social...",
    instagram: Instagram(
      backgroundBottomColor: "#FF7391",
      backgroundTopColor: "#591E78",
      attributionURL: "https://deep-link-url",
      imagePath: imagePath,
    ),
  );
}
Follow Me:

instagram Telegram LinkedIn GitHub

所属分类

依赖

依赖清单 3 项

源码仓库

使用此插件的项目

暂无相关数据。