<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shekar Mudaliyar💙</title>
    <description>The latest articles on DEV Community by Shekar Mudaliyar💙 (@0_b1nary).</description>
    <link>https://dev.to/0_b1nary</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F286447%2F9ca17e2a-8389-4d60-90d9-ac9314611ded.jpg</url>
      <title>DEV Community: Shekar Mudaliyar💙</title>
      <link>https://dev.to/0_b1nary</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/0_b1nary"/>
    <language>en</language>
    <item>
      <title>Sharing on Instagram Stories, Facebook stories and more direct shares in Flutter using social_share plugin.</title>
      <dc:creator>Shekar Mudaliyar💙</dc:creator>
      <pubDate>Mon, 23 Dec 2019 08:10:41 +0000</pubDate>
      <link>https://dev.to/0_b1nary/sharing-on-instagram-stories-facebook-stories-and-more-direct-shares-in-flutter-using-socialshare-plugin-3b7k</link>
      <guid>https://dev.to/0_b1nary/sharing-on-instagram-stories-facebook-stories-and-more-direct-shares-in-flutter-using-socialshare-plugin-3b7k</guid>
      <description>&lt;p&gt;A Flutter plugin including a wide variety of sharing options you'll need to share directly to certain popular apps or just share with default native share.&lt;br&gt;
You can use this plugin to share on Instagram Stories, Facebook Stories, Twitter, Sms, Copy to clipboard, Whatsapp, and also default share with or without an image.&lt;/p&gt;
&lt;h2&gt;
  
  
  This plugin is iOS only! Android is still in progress
&lt;/h2&gt;

&lt;p&gt;So, without wasting more time on intros. Let's start&lt;/p&gt;

&lt;p&gt;Create a new Flutter project &lt;code&gt;flutter create social_share_example&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;Add the  &lt;a href="https://pub.dev/packages/social_share/" rel="noopener noreferrer"&gt;social_share&lt;/a&gt; plugin in your pubspec.yaml file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dependencies:
  social_share: ^1.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To install plugins run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;flutter pub get
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Import plugin to your file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:social_share/social_share.dart';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Add this to your &lt;code&gt;Info.plist&lt;/code&gt; to use the share on Instagram and facebook story
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;key&amp;gt;LSApplicationQueriesSchemes&amp;lt;/key&amp;gt;
    &amp;lt;array&amp;gt;
    &amp;lt;string&amp;gt;instagram-stories&amp;lt;/string&amp;gt;
    &amp;lt;string&amp;gt;facebook-stories&amp;lt;/string&amp;gt;
    &amp;lt;string&amp;gt;facebook&amp;lt;/string&amp;gt;
    &amp;lt;string&amp;gt;instagram&amp;lt;/string&amp;gt;
    &amp;lt;string&amp;gt;twitter&amp;lt;/string&amp;gt;
    &amp;lt;string&amp;gt;whatsapp&amp;lt;/string&amp;gt;
    &amp;lt;/array&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Add this if you are using the share on facebook. For this, you have to create an app on &lt;a href="https://developers.facebook.com/" rel="noopener noreferrer"&gt;https://developers.facebook.com/&lt;/a&gt; and get the App ID
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;key&amp;gt;FacebookAppID&amp;lt;/key&amp;gt;
&amp;lt;string&amp;gt;xxxxxxxxxxxxxxx&amp;lt;/string&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is all you need to integrate this plugin in your project now lets start using it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Click-Click-Click
&lt;/h2&gt;

&lt;p&gt;I'm using &lt;a href="https://pub.dev/packages/screenshot" rel="noopener noreferrer"&gt;screenshot&lt;/a&gt; plugin to capture the screen.&lt;/p&gt;

&lt;p&gt;Let's install that too in your &lt;code&gt;pubspec.yaml&lt;/code&gt; file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dependencies:
  screenshot: ^0.1.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and then&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;flutter pub get
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then create a raised button to make a button when on clicked we can share.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RaisedButton(
                  onPressed: () async {
                    await screenshotController.capture().then((image) async {
                     // sharing methods here !!
                    });
                  },
                  child: Text("Share"),
                ),
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;inside the await screentshot function you can add the methods from the plugin using &lt;code&gt;Socialshare&lt;/code&gt; class.&lt;/p&gt;

&lt;h4&gt;
  
  
  shareInstagramStory
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SocialShare.shareInstagramStory(imageFile.path, "#ffffff",
                              "#000000", "https://deep-link-url");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  shareInstagramStorywithBackground
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; SocialShare.shareInstagramStorywithBackground(image.path, "https://deep-link-url",
                              backgroundImagePath: backgroundimage.path);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  shareFacebookStory
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SocialShare.shareFacebookStory(image.path,"#ffffff","#000000",
                              "https://deep-link-url","facebook-app-id");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  copyToClipboard
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SocialShare.copyToClipboard("This is Social Share plugin");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  shareTwitter
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//without hashtags
SocialShare.shareTwitter("This is Social Share plugin");

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

&lt;/div&gt;



&lt;h4&gt;
  
  
  shareSms
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//without url link in the message
SocialShare.shareSms("This is Social Share Sms example");

//with url link in message
SocialShare.shareSms("This is Social Share Sms example",url: "https://micro.volvmedia.com/");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  shareWhatsapp
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SocialShare.shareWhatsapp("Hello World");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  shareOptions
&lt;/h4&gt;

&lt;p&gt;This will open the default native share options&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//without an image
SocialShare.shareOptions("Hello world");

//with an image
SocialShare.shareOptions("Hello world",imagePath: image.path);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it now you can use the sharing feature on Flutter.&lt;/p&gt;

&lt;h3&gt;
  
  
  Buy me a ☕ !!
&lt;/h3&gt;

&lt;p&gt;((More coffee == more code) == more fast updates)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://paypal.me/b1naryishere/10" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FDonate-PayPal-green.svg" alt="Donate"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Get in touch!
&lt;/h3&gt;

&lt;p&gt;Feel free to get in touch with me regarding any questions or queries.&lt;br&gt;
&lt;a href="https://github.com/ShekarMudaliyar" rel="noopener noreferrer"&gt;&lt;br&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fedent.github.io%2FSuperTinyIcons%2Fimages%2Fsvg%2Fgithub.svg" title="Github"&gt;&lt;br&gt;
&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.linkedin.com/in/shekar-mudaliyar-648519139/" rel="noopener noreferrer"&gt;&lt;br&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fedent.github.io%2FSuperTinyIcons%2Fimages%2Fsvg%2Flinkedin.svg" title="LinkedIn"&gt;&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.instagram.com/the_one_with_codes/" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fedent.github.io%2FSuperTinyIcons%2Fimages%2Fsvg%2Finstagram.svg" title="Instagram"&gt;&lt;br&gt;
&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/0_B1NARY" rel="noopener noreferrer"&gt;&lt;br&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fedent.github.io%2FSuperTinyIcons%2Fimages%2Fsvg%2Ftwitter.svg" title="Twitter"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>ios</category>
    </item>
  </channel>
</rss>
