# share **Repository Path**: flutter-mirror/share ## Basic Information - **Project Name**: share - **Description**: 分享功能 - **Primary Language**: Dart - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2022-03-30 - **Last Updated**: 2023-12-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # flutter_share_me [![pub package](https://img.shields.io/pub/v/flutter_share_me.svg)](https://pub.dartlang.org/packages/flutter_share_me) [![style: lint](https://img.shields.io/badge/style-lint-4BC0F5.svg)](https://pub.dev/packages/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](https://flutter.io/platform-plugins/). 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 ``` ... //add this ``` string.xml: ``` 343254889799245 ``` #### IOS ##### setup facebook make sure you add below deatils in your plist file. ``` FacebookAppID fbid CFBundleURLTypes CFBundleURLSchemes fb-your-fb-id ``` Note-: Make sure you add fb in at start of your fb Id in CFBundleURLSchemes. Add below value in url scheme(Refer to example). ```LSApplicationQueriesSchemes fbauth2 fbapi fbapi20130214 fbapi20130410 fbapi20130702 fbapi20131010 fbapi20131219 fbapi20140410 fbapi20140116 fbapi20150313 fbapi20150629 fbapi20160328 fbauth fb-messenger-share-api fbauth2 fbshareextension tg ``` ### Setup Whatsapp Make sure you add whatsapp in plist. ````LSApplicationQueriesSchemes whatsapp ```` #### Setup Twiter ````LSApplicationQueriesSchemes twitter ```` ## 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: [ 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](https://github.com/OpenFlutter/flutter_share_me/blob/master/example/lib/main.dart)