Skip to main content
RapidDev - Software Development Agency
flutterflow-tutorials

How to Build a Social Sharing Feature in FlutterFlow

Add social sharing using a Custom Action with the share_plus package to invoke the native OS share sheet. Compose shareable messages with dynamic deep link URLs that route back to specific content in your app. Track share events in a Firestore share_events collection for analytics, and configure Open Graph meta tags on your web deployment so shared links display rich previews on WhatsApp, Twitter, and other platforms.

What you'll learn

  • How to invoke the native share sheet using a Custom Action with share_plus
  • How to generate deep link URLs that open specific content in your app
  • How to track share events in Firestore for analytics
  • How to configure Open Graph meta tags for rich link previews
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner8 min read15-20 minFlutterFlow Free+ (Custom Action required for share_plus)March 2026RapidDev Engineering Team
TL;DR

Add social sharing using a Custom Action with the share_plus package to invoke the native OS share sheet. Compose shareable messages with dynamic deep link URLs that route back to specific content in your app. Track share events in a Firestore share_events collection for analytics, and configure Open Graph meta tags on your web deployment so shared links display rich previews on WhatsApp, Twitter, and other platforms.

Native share sheet with deep links and share tracking

Social sharing lets users spread your app's content to WhatsApp, Twitter, Messages, email, and any other app on their phone. This tutorial implements sharing in FlutterFlow using the share_plus package for the native OS share sheet, Firebase Dynamic Links (or a custom URL scheme) for deep linking back to specific content, and a Firestore collection for tracking share events. You will also configure Open Graph meta tags so shared links display a title, description, and image preview on social platforms.

Prerequisites

  • A FlutterFlow project with content pages that users would want to share
  • Firebase/Firestore connected for share event tracking
  • Basic understanding of Custom Actions in FlutterFlow
  • A deployed web version of your app (for deep link URLs and OG tags)

Step-by-step guide

1

Create a Custom Action to invoke the native share sheet

In FlutterFlow, go to Custom Code and create a new Custom Action named shareContent. Add two parameters: shareText (String) and shareSubject (String, optional). Add the share_plus package as a dependency (pub.dev: share_plus). In the action body, import the package and call Share.share(shareText, subject: shareSubject). This opens the native OS share sheet on both iOS and Android, letting users pick WhatsApp, Twitter, Messages, email, or any other installed app. The shareText parameter will contain the composed message with the deep link URL. Return void from the action.

share_content.dart
1// Custom Action: shareContent
2import 'package:share_plus/share_plus.dart';
3
4Future shareContent(
5 String shareText,
6 String? shareSubject,
7) async {
8 await Share.share(
9 shareText,
10 subject: shareSubject ?? '',
11 );
12}

Expected result: A reusable Custom Action is available that opens the native share sheet with any text content.

2

Generate shareable deep link URLs for your content

For each piece of shareable content (articles, products, profiles), construct a deep link URL that routes to the correct page in your app. The simplest approach is to use your web app's URL with a path parameter: https://yourapp.com/content/{contentId}. If you use Firebase Dynamic Links, create a link with the deep link pointing to your app's content page and fallback URLs for web. Store the generated link as a Custom Function or compute it inline: 'https://yourapp.com/content/' + contentDocument.id. When the share button is tapped, compose the share message by combining a user-friendly text with the deep link: 'Check out "' + contentTitle + '" on MyApp: ' + deepLinkUrl. Pass this composed string to the shareContent Custom Action.

Expected result: Each shareable content item has a unique URL that opens the correct page when tapped from an external platform.

3

Add share buttons to content pages and cards

On each content page or card Component, add an IconButton with the share icon (Icons.share). On Tap Action Flow: first, compose the share message using a Custom Function that takes the content title and ID, returning a string like 'Check out "UX Design Basics" on MyApp: https://yourapp.com/content/abc123'. Then call the shareContent Custom Action with this string as shareText and the content title as shareSubject. For a custom share menu instead of the OS default, create a BottomSheet with specific platform icons (WhatsApp, Twitter, Copy Link). The Copy Link option uses a Custom Action with Clipboard.setData(ClipboardData(text: url)) and shows a SnackBar confirming the link was copied.

Expected result: Share buttons appear on content pages and cards. Tapping opens the native share sheet with a pre-composed message and link.

4

Track share events in Firestore for analytics

Create a share_events collection in Firestore with fields: contentId (String), contentType (String: 'article', 'product', 'profile'), userId (String), timestamp (Timestamp). In the share button's Action Flow, before calling the shareContent Custom Action, add a Create Document action that writes a share event to this collection. This tracks which content is shared most and by whom. On your admin dashboard, query share_events grouped by contentId to show a leaderboard of most-shared content. Add a shareCount field on the content document and increment it with FieldValue.increment(1) for quick display on content cards without querying the events collection.

Expected result: Each share action creates a Firestore event document and increments the content's shareCount for analytics.

5

Configure Open Graph meta tags for rich link previews

When users share a link on WhatsApp, Twitter, or Facebook, these platforms read Open Graph meta tags from the URL to generate a preview card with title, description, and image. For your FlutterFlow web deployment, add OG meta tags in the HTML head. Go to your FlutterFlow project settings or custom head tag section and add: og:title (content title), og:description (content summary), og:image (thumbnail URL, minimum 1200x630px for best display), og:url (the canonical URL), and og:type ('article' or 'website'). For dynamic content where each page has different metadata, you need server-side rendering or a Cloud Function that serves the HTML with dynamic OG tags based on the URL path. Without this, all shared links show the same generic preview.

Expected result: Links shared on social platforms display a rich preview card with the correct title, description, and image.

Complete working example

Social Sharing Architecture
1Firestore Data Model:
2 share_events/{eventId}
3 contentId: String ("article_abc123")
4 contentType: String ("article" | "product" | "profile")
5 userId: String (current user UID)
6 timestamp: Timestamp
7
8Content documents gain:
9 shareCount: Integer (increment on each share)
10
11Custom Action shareContent:
12 Parameters: shareText (String), shareSubject (String?)
13 Package: share_plus
14 Body: Share.share(shareText, subject: shareSubject)
15
16Custom Function composeShareMessage:
17 Parameters: title (String), contentId (String)
18 Returns: 'Check out "$title" on MyApp: https://yourapp.com/content/$contentId'
19
20Share Button (on content card or page):
21 IconButton (Icons.share)
22 On Tap Action Flow:
23 1. Create Document share_events (contentId, userId, timestamp)
24 2. Update Document content doc: shareCount FieldValue.increment(1)
25 3. Custom Function composeShareMessage(title, id) result
26 4. Custom Action shareContent(result, title)
27 Native OS share sheet opens
28
29Custom Share BottomSheet (optional):
30 Row of platform icons
31 WhatsApp Launch URL: whatsapp://send?text={encodedMessage}
32 Twitter Launch URL: twitter.com/intent/tweet?text={encoded}
33 Copy Link Clipboard.setData SnackBar "Link copied"
34 More shareContent Custom Action (OS share sheet)
35
36Open Graph Meta Tags (web deployment):
37 <meta property="og:title" content="{dynamic title}" />
38 <meta property="og:description" content="{dynamic description}" />
39 <meta property="og:image" content="{image URL, 1200x630px}" />
40 <meta property="og:url" content="{canonical URL}" />
41 <meta property="og:type" content="article" />

Common mistakes when building a Social Sharing Feature in FlutterFlow

Why it's a problem: Sharing a bare URL without Open Graph tags configured

How to avoid: Add og:title, og:description, og:image (minimum 1200x630px), and og:url meta tags to your web deployment HTML head. For dynamic content, use a server-side function to inject content-specific tags based on the URL path.

Why it's a problem: Trying to detect which platform the user shared to

How to avoid: Log the share event when the user taps the Share button, before the OS sheet opens. Accept that this slightly overcounts shares (some users will dismiss the sheet without sending), but it is the industry-standard approach.

Why it's a problem: Sharing long URLs that break or look ugly in messages

How to avoid: Use a URL shortener (Bitly API, Firebase Dynamic Links successor, or your own short domain) to create compact, branded links like https://myapp.link/abc. Store the short URL on the content document for instant retrieval.

Best practices

  • Use the share_plus package for cross-platform native share sheet support
  • Compose share messages with a human-friendly sentence plus the link, not just a bare URL
  • Track share events in Firestore for content analytics and viral tracking
  • Configure Open Graph meta tags with images at minimum 1200x630px for rich previews
  • Offer a Copy Link option alongside the share sheet for users who prefer manual sharing
  • Use compact, branded short URLs instead of long Firestore paths
  • Test shared links on WhatsApp, Twitter, and iMessage to verify preview cards render correctly

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

Write a Flutter Custom Action using the share_plus package that shares a composed message containing a title and deep link URL via the native OS share sheet. Include parameters for the share text and subject.

FlutterFlow Prompt

Add a share icon button to my content cards. When tapped, it should open the native share sheet with a message like 'Check out this article on MyApp' followed by a link to the content page.

Frequently asked questions

Does the share_plus package work on both iOS and Android?

Yes. share_plus uses the native UIActivityViewController on iOS and the ACTION_SEND intent on Android. It also works on web, macOS, and Linux with platform-appropriate share mechanisms.

How do I share images along with text?

Use Share.shareXFiles() from share_plus to share image files. First save the image locally as a temporary file using a Custom Action, then pass it as an XFile to shareXFiles along with the text message.

Can I deep link directly to specific content in my mobile app?

Yes. Configure Firebase Dynamic Links (or App Links for Android / Universal Links for iOS) so that tapping a shared URL opens your app directly to the content page. Without this setup, the link opens in the browser instead.

How do I make Open Graph tags dynamic for different content pages?

FlutterFlow web apps are single-page applications, so the same HTML serves every route. To serve dynamic OG tags, use a Cloud Function or edge function that intercepts social media crawlers (via User-Agent detection) and returns customized HTML with OG tags based on the URL path.

How do I add a referral code to shared links?

Append the user's referral code as a query parameter to the share URL: https://yourapp.com/content/abc123?ref=USER_CODE. On the receiving end, parse the ref parameter on app open and credit the referrer.

Can RapidDev help build a viral sharing and referral system?

Yes. A production viral loop needs deep linking across iOS and Android, referral tracking, attribution analytics, A/B tested share messages, and incentive mechanics. RapidDev can architect the full system beyond basic share_plus integration.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.