DEV Community

Cover image for Sharing on Instagram Stories, Facebook stories and more direct shares in Flutter using social_share plugin.
Shekar Mudaliyar💙
Shekar Mudaliyar💙

Posted on

Sharing on Instagram Stories, Facebook stories and more direct shares in Flutter using social_share plugin.

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.
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.

This plugin is iOS only! Android is still in progress

So, without wasting more time on intros. Let's start

Create a new Flutter project flutter create social_share_example


Add the social_share plugin in your pubspec.yaml file

  social_share: ^1.0.0

To install plugins run

flutter pub get

Import plugin to your file

import 'package:social_share/social_share.dart';

Add this to your Info.plist to use the share on Instagram and facebook story


Add this if you are using the share on facebook. For this, you have to create an app on and get the App ID


This is all you need to integrate this plugin in your project now lets start using it.


I'm using screenshot plugin to capture the screen.

Let's install that too in your pubspec.yaml file

  screenshot: ^0.1.1

and then

flutter pub get

Then create a raised button to make a button when on clicked we can share.

                  onPressed: () async {
                    await screenshotController.capture().then((image) async {
                     // sharing methods here !!
                  child: Text("Share"),

inside the await screentshot function you can add the methods from the plugin using Socialshare class.


SocialShare.shareInstagramStory(imageFile.path, "#ffffff",
                              "#000000", "https://deep-link-url");


 SocialShare.shareInstagramStorywithBackground(image.path, "https://deep-link-url",
                              backgroundImagePath: backgroundimage.path);




SocialShare.copyToClipboard("This is Social Share plugin");


//without hashtags
SocialShare.shareTwitter("This is Social Share plugin");

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


//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: "");


SocialShare.shareWhatsapp("Hello World");


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);

That's it now you can use the sharing feature on Flutter.

Buy me a ☕ !!

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


Get in touch!

Feel free to get in touch with me regarding any questions or queries.

Top comments (0)