share_intent_package 1.0.2 copy "share_intent_package: ^1.0.2" to clipboard
share_intent_package: ^1.0.2 copied to clipboard

The easiest Flutter share intent plugin. Receive text, images, videos, documents from other apps with automated setup. iOS ShareExtension + Android intent filters made simple.

Share Intent Package #

The easiest Flutter share intent plugin - Receive text, images, videos, and documents from other apps with automated setup.

pub package

✨ Features #

  • 🚀 One-command setup for iOS ShareExtension
  • 📱 Native iOS & Android share intent support
  • 📝 All content types: Text, URLs, Images, Videos, Documents
  • 🔄 Real-time sharing while app is running
  • 🎯 Cold start sharing when app is closed
  • 📦 Simple Android setup with copy-paste intent filters
  • 🛠️ Automatic iOS configuration with setup scripts

📋 Supported Content Types #

Content Type iOS Android Description
Text Plain text, rich text
URLs Web links, deep links
Images JPEG, PNG, GIF, WebP
Videos MP4, MOV, AVI
Documents PDF, DOC, XLS, ZIP
Multiple Files Multiple items at once

🚀 Quick Start #

1. Add Dependency #

flutter pub add share_intent_package

2. Setup Platforms (One Command Each!) #

iOS Setup:

dart run share_intent_package:setup_ios_clean
cd ios && pod install && cd ..

Android Setup:

dart run share_intent_package:setup_android

3. Alternative Android Setup (Manual) #

If the automated setup doesn't work, manually Add the following intent filters to your android/app/src/main/AndroidManifest.xml file inside the <activity> tag:

<!-- Intent filters for share functionality -->
<!-- Handle text sharing -->
<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" />
</intent-filter>

<!-- Handle single image sharing -->
<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="image/*" />
</intent-filter>

<!-- Handle single video sharing -->
<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="video/*" />
</intent-filter>

<!-- Handle single file sharing -->
<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="application/*" />
</intent-filter>

<!-- Handle multiple files sharing -->
<intent-filter>
    <action android:name="android.intent.action.SEND_MULTIPLE" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="image/*" />
</intent-filter>

<intent-filter>
    <action android:name="android.intent.action.SEND_MULTIPLE" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="video/*" />
</intent-filter>

<!-- Handle any type of content -->
<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="*/*" />
</intent-filter>

<intent-filter>
    <action android:name="android.intent.action.SEND_MULTIPLE" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="*/*" />
</intent-filter>

4. Use in Your App #

import 'package:share_intent_package/share_intent_package.dart';

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  ShareData? _initialShare;
  StreamSubscription<ShareData>? _shareSubscription;
  final List<ShareData> _sharedData = [];

  @override
  void initState() {
    super.initState();
    initShareIntent();
  }

  Future<void> initShareIntent() async {
    // Initialize
    await ShareIntentPackage.instance.init();

    // Get initial share (cold start)
    final initialShare = await ShareIntentPackage.instance.getInitialShare();
    if (initialShare != null) {
      setState(() {
        _initialShare = initialShare;
        _sharedData.add(initialShare);
      });
    }

    // Listen for new shares (while app is running)
    _shareSubscription = ShareIntentPackage.instance.getShareStream().listen(
      (ShareData shareData) {
        setState(() {
          _sharedData.add(shareData);
        });
      },
    );
  }

  @override
  void dispose() {
    _shareSubscription?.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('Share Intent Example')),
        body: ListView.builder(
          itemCount: _sharedData.length,
          itemBuilder: (context, index) {
            final share = _sharedData[index];
            return Card(
              child: ListTile(
                title: Text(share.text ?? 'File: ${share.filePaths?.first}'),
                subtitle: Text('Type: ${share.mimeType}'),
              ),
            );
          },
        ),
      ),
    );
  }
}

📱 What Users See #

iOS #

  1. User shares content from any app (Photos, Safari, etc.)
  2. Your app appears in the iOS share menu
  3. Content instantly appears in your Flutter app

Android #

  1. User shares content from any app
  2. Your app appears in "Share with..." menu
  3. Content instantly appears in your Flutter app

🛠️ API Reference #

ShareIntentPackage (Singleton) #

// Initialize the plugin
await ShareIntentPackage.instance.init();

// Get initial share data (when app opened from share)
ShareData? initialShare = await ShareIntentPackage.instance.getInitialShare();

// Listen for share events while app is running
Stream<ShareData> shareStream = ShareIntentPackage.instance.getShareStream();

// Reset/clear current share data
await ShareIntentPackage.instance.reset();

// Get platform version (for debugging)
String? version = await ShareIntentPackage.instance.getPlatformVersion();

ShareData Class #

class ShareData {
  final String? text;           // Shared text content
  final List<String>? filePaths; // Paths to shared files
  final String? mimeType;       // MIME type of content
  final Map<String, dynamic>? extraData; // Additional data

  bool get hasData => text != null || (filePaths?.isNotEmpty ?? false);
}

🔧 Advanced Configuration #

iOS Custom Setup #

For advanced iOS configuration, see the manual setup guide in the repository. The automated setup script handles most use cases.

Manual iOS Configuration #

If automatic setup doesn't work, follow the manual setup guide in the repository.

🐛 Troubleshooting #

iOS Issues #

App doesn't appear in share menu:

# Run setup script again
dart run share_intent_package:setup_ios_clean
cd ios && pod install && cd ..
# Clean and rebuild
flutter clean && flutter build ios

Build errors:

# Update iOS deployment target
# In ios/Podfile, ensure: platform :ios, '11.0'
# Clean and reinstall pods
cd ios && rm -rf Pods Podfile.lock && pod install && cd ..

Android Issues #

App doesn't appear in share menu:

# Run Android setup script
dart run share_intent_package:setup_android
# OR manually add intent filters to AndroidManifest.xml (see setup section)
# Clean and rebuild
flutter clean && flutter build apk

Share not working after setup:

# Verify intent filters are in android/app/src/main/AndroidManifest.xml
# Check that they're inside the main <activity> tag
# Clean and rebuild
flutter clean && flutter build apk

Permission issues:

  • The plugin automatically includes necessary permissions
  • No additional permissions required for basic functionality

📄 Platform Requirements #

Platform Minimum Version
iOS 11.0+
Android API 21+ (Android 5.0)
Flutter 3.3.0+
Dart 3.10.1+

🤝 Contributing #

Contributions are welcome! Please read our Contributing Guide.

📝 License #

This project is licensed under the MIT License - see the LICENSE file for details.

⭐ Show Your Support #

If this plugin helped you, please ⭐ star the repo and 👍 like the package on pub.dev!


Made with ❤️ for the Flutter community

7
likes
0
points
687
downloads

Publisher

unverified uploader

Weekly Downloads

The easiest Flutter share intent plugin. Receive text, images, videos, documents from other apps with automated setup. iOS ShareExtension + Android intent filters made simple.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on share_intent_package

Packages that implement share_intent_package