share_intent_package 1.0.0 copy "share_intent_package: ^1.0.0" to clipboard
share_intent_package: ^1.0.0 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
  • 📦 Zero configuration Android setup
  • 🛠️ 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. iOS Setup (One Command!) #

cd ios && dart ../bin/setup_ios_clean.dart && pod install && cd ..

3. Android Setup (Automatic!) #

Android configuration is automatically handled by the plugin. No manual setup required!

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, you can also use:

# Alternative setup scripts
dart ../bin/setup_ios.dart        # Basic setup
dart ../bin/setup_ios_ruby.rb     # Ruby-based setup (requires xcodeproj gem)
../bin/setup_ios.sh              # Shell script version

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
cd ios && dart ../bin/setup_ios_clean.dart && 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 #

Share not working:

# Verify intent filters are registered (automatic)
# Clean and rebuild
flutter clean && flutter build apk

📄 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