Add social media sharing to FlutterFlow using the share_plus package in a Custom Action. Call Share.share(url) to open the native iOS/Android share sheet which presents every installed app (WhatsApp, Twitter, Messages, etc.) as a sharing target. For rich link previews on social platforms, configure Open Graph title, description, and image in FlutterFlow's Publish settings before publishing your app.
Native share sheet + deep links + Open Graph tags for social sharing
FlutterFlow does not have a built-in share widget, but the share_plus Flutter package gives you access to the native iOS share sheet and Android share dialog in a single Custom Action. This means users can share your content to any app installed on their device — no need to build integrations with each social platform individually. The share sheet handles WhatsApp, Twitter, Instagram Stories, iMessage, email, and hundreds of other targets automatically. This tutorial covers the full social sharing stack: triggering the share sheet, structuring the shared payload, configuring deep links so shared URLs open the app, setting up Open Graph tags for rich previews, and tracking shares in Firestore.
Prerequisites
- A FlutterFlow project with content to share (product pages, articles, profiles, or any shareable content)
- FlutterFlow project published to web (needed to test Open Graph link previews)
- Basic understanding of FlutterFlow Custom Actions
- Firebase project connected (for optional share event tracking)
Step-by-step guide
Add share_plus package to FlutterFlow Pubspec Dependencies
Add share_plus package to FlutterFlow Pubspec Dependencies
In FlutterFlow, navigate to Custom Code in the left sidebar. Click Pubspec Dependencies. Click Add Dependency. Search for share_plus and add it — use version ^10.0.0 or the latest stable version. Click Save. Wait for the package to compile. Once compiled, you can import it in Custom Actions using import 'package:share_plus/share_plus.dart'. The share_plus package works on iOS, Android, and web. On web, it falls back to the Web Share API where supported, and opens a new tab for sharing otherwise.
Expected result: share_plus appears in the Pubspec Dependencies list with a green compile status indicator.
Create the shareContent Custom Action
Create the shareContent Custom Action
In Custom Code, click Add Custom Action. Name it shareContent. Add three String parameters: shareText (the message to share), shareUrl (the URL to include), and contentId (for tracking — the ID of the post, product, or content being shared). In the action body, write the sharing logic. For text + URL: call Share.share('$shareText\n$shareUrl'). For sharing an image from a network URL: first download the image bytes with http.get, save to a temp file using path_provider's getTemporaryDirectory(), then call Share.shareXFiles([XFile(tempFile.path)], text: shareText). Click Save and Compile Code to verify there are no import errors.
1import 'package:share_plus/share_plus.dart';2import 'package:cloud_firestore/cloud_firestore.dart';34Future shareContent(5 String shareText,6 String shareUrl,7 String contentId,8) async {9 final String fullText = '$shareText\n$shareUrl';1011 await Share.share(12 fullText,13 subject: shareText,14 );1516 // Track the share event in Firestore17 await FirebaseFirestore.instance18 .collection('share_events')19 .add({20 'contentId': contentId,21 'sharedAt': FieldValue.serverTimestamp(),22 'shareText': shareText,23 });24}Expected result: Custom Action compiles without errors. The action appears in the Action Flow editor as an available Custom Action.
Add a share button and connect the Custom Action in the Action Flow
Add a share button and connect the Custom Action in the Action Flow
On the page with shareable content, add an IconButton widget. Set the icon to Icons.share (the standard share icon recognized across platforms). In the widget's On Tap action flow, add an Action → Custom Actions → shareContent. Bind the parameters: shareText to a string like 'Check out [content title]' built from page state or query data, shareUrl to the deep link URL for this content item (or your app's web URL if deep links aren't set up yet), and contentId to the content document ID from the Backend Query. On iOS, tapping this button opens the share sheet. On Android, it opens the Android share dialog.
Expected result: Tapping the share button on a physical device opens the native share sheet with the content text and URL pre-populated.
Configure Open Graph meta tags in FlutterFlow Publish settings
Configure Open Graph meta tags in FlutterFlow Publish settings
For rich link previews when users share your URL on WhatsApp, Twitter, or iMessage, your app needs Open Graph meta tags. In FlutterFlow, click the Publish icon in the top-right corner. In the publish dialog, locate the Metadata section. Fill in: Title (the og:title — what appears as the link card heading, max 60 chars), Description (the og:description — the preview subtitle, max 155 chars), and OG Image (upload a 1200×630px image — this appears as the card thumbnail). Click Save, then click Publish or Update. After publishing, test your OG tags using https://www.opengraph.xyz/ — paste your app URL and verify the preview renders correctly.
Expected result: Sharing your app URL on WhatsApp or Twitter shows a rich link card with your configured title, description, and image instead of a blank or broken preview.
Set up Firebase Dynamic Links for deep linking from shared URLs
Set up Firebase Dynamic Links for deep linking from shared URLs
Firebase Dynamic Links lets you create URLs that open your FlutterFlow app to a specific page when tapped on a mobile device, and fall back to the app store or web URL if the app isn't installed. In Firebase Console, navigate to Engage → Dynamic Links. Click Get Started. Set a URL prefix (e.g., yourapp.page.link). Create a new Dynamic Link: set the Long Link to your content URL, the iOS/Android behavior to Open the app if installed, and the fallback to the App Store/Play Store link. In FlutterFlow, add the firebase_dynamic_links package to Pubspec Dependencies. Create a Custom Action that initializes the dynamic links listener on app startup: FirebaseDynamicLinks.instance.getInitialLink() for cold start and onLink.listen() for foreground deep links. Each listener navigates to the target page using the extracted path parameter.
Expected result: Tapping a shared dynamic link on mobile opens the FlutterFlow app directly to the correct content page, or redirects to the App Store if the app is not installed.
Complete working example
1// Custom Action: shareContent2// Triggers native share sheet with text + URL3// Tracks share event in Firestore45import 'package:share_plus/share_plus.dart';6import 'package:cloud_firestore/cloud_firestore.dart';7import 'package:firebase_auth/firebase_auth.dart';89Future shareContent(10 String shareText,11 String shareUrl,12 String contentId,13) async {14 // Build the full share message15 final String message = '$shareText\n\n$shareUrl';1617 // Open native share sheet (iOS share sheet / Android share dialog)18 final ShareResult result = await Share.shareWithResult(19 message,20 subject: shareText, // used by email apps as subject line21 );2223 // Only track if user completed the share (not cancelled)24 if (result.status == ShareResultStatus.success) {25 final String? uid = FirebaseAuth.instance.currentUser?.uid;26 await FirebaseFirestore.instance27 .collection('share_events')28 .add({29 'contentId': contentId,30 'userId': uid ?? 'anonymous',31 'sharedVia': result.raw, // platform that received the share32 'sharedAt': FieldValue.serverTimestamp(),33 });34 }35}Common mistakes
Why it's a problem: Sharing a bare URL without Open Graph meta tags configured in FlutterFlow Publish settings
How to avoid: Before publishing your app, click the Publish icon → Metadata section → fill in Title, Description, and OG Image (1200×630px). After updating, clear your platform's URL cache — for WhatsApp use https://wa.me/debug, for Facebook use https://developers.facebook.com/tools/debug/.
Why it's a problem: Calling Share.share from the main UI thread synchronously without await
How to avoid: Always await Share.share or Share.shareWithResult. Use Share.shareWithResult if you want to know which platform the user shared to or whether they dismissed the sheet without sharing.
Why it's a problem: Using hardcoded platform-specific share methods (Twitter URL scheme, WhatsApp deep link) instead of the native share sheet
How to avoid: Always use Share.share() which opens the native OS share sheet. The OS presents only the apps installed on the user's device. No platform-specific code is needed — WhatsApp, Twitter, Messenger, email, and hundreds of other apps all appear automatically if installed.
Best practices
- Use Share.shareWithResult instead of Share.share when you want to track whether the user completed the share versus dismissed the sheet without sharing
- Compress images before sharing — Share.shareXFiles with a full-resolution photo causes slow sharing and may fail on platforms with file size limits
- Build share URLs with UTM parameters (utm_source=app&utm_medium=share&utm_campaign=content) so you can attribute traffic from shares in Google Analytics or Firebase Analytics
- Test share functionality on physical devices, not the FlutterFlow emulator — the share sheet behaves differently in simulators and some platforms do not appear in test environments
- For content-specific deep links, generate the Firebase Dynamic Link in the action flow before opening the share sheet so the shared URL is app-specific, not just the app home URL
- Add a share count display next to the share button by counting documents in share_events where contentId matches — encourages more sharing when users see others have shared the same content
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I am building a FlutterFlow app and want to add a share button that opens the native iOS/Android share sheet. Write me: (1) A Flutter Custom Action using share_plus that shares text + URL and tracks the share in Firestore, (2) How to configure Open Graph meta tags for rich link previews, and (3) How to set up Firebase Dynamic Links so shared URLs open the app to a specific content page.
Add a share icon button to my content card. When tapped, it should open the native share sheet with the message 'Check out [contentTitle] on [appName]' followed by the content URL. After the user shares, write a document to the share_events Firestore collection with contentId, userId, and sharedAt timestamp.
Frequently asked questions
Does share_plus work on iOS, Android, and web in FlutterFlow?
Yes. On iOS, Share.share opens the native iOS share sheet. On Android, it opens the Android share intent chooser. On web, it uses the Web Share API where the browser supports it (Chrome on Android, Safari on iOS), and falls back to copying the URL to clipboard on browsers without Web Share API support (like desktop Chrome).
How do I share an image from Firebase Storage in FlutterFlow?
Download the image bytes from Firebase Storage to a temporary file first, then use Share.shareXFiles. In your Custom Action: use the http package to GET the storage URL, write the bytes to a file in getTemporaryDirectory(), then call Share.shareXFiles([XFile(tempFilePath)], text: caption). Make sure to add http and path_provider to Pubspec Dependencies alongside share_plus.
Why does my shared link not show a preview image on WhatsApp?
WhatsApp caches Open Graph data aggressively. If you recently added or changed your OG image, WhatsApp may still show the old (or blank) preview for hours. To force a cache refresh for testing, use the WhatsApp link debug tool at https://wa.me/debug — paste your URL and click Fetch Info. Also verify your OG image is a publicly accessible URL (not behind authentication), is at least 200×200px, and is under 5MB.
How can I track which social platform users share to?
Use Share.shareWithResult instead of Share.share. The result object contains a raw field that returns the platform identifier string (e.g., 'com.whatsapp' on Android, 'com.apple.UIKit.activity.Message' on iOS) when the user completes the share. Store this in Firestore alongside the share event. Note: on some platforms the identifier is not available and the raw field returns an empty string even on successful shares.
Can I share directly to a specific platform like WhatsApp without the share sheet?
Technically yes — WhatsApp has a URL scheme (whatsapp://send?text=...) and web URL (https://wa.me/?text=...) that open WhatsApp directly. You can use the url_launcher package to open these. However, this approach is fragile (breaks if WhatsApp changes its scheme), does not work if WhatsApp is not installed, and skips all other sharing targets. Only use direct platform URLs if you have a specific UX requirement for a single target platform.
What if I cannot get the share sheet working on my device?
The share sheet only works on physical devices, not on the FlutterFlow web preview or desktop emulators. For iOS, ensure you are testing on a real iPhone or iPad. For Android, test on a physical Android device. If the share sheet opens but immediately closes, ensure the shareText and shareUrl parameters are non-empty strings — sharing an empty string causes the sheet to dismiss instantly on some platforms. RapidDev can review your Custom Action implementation if you are still stuck.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation