Search packages, repositories and app categories

flutter_share cover
Package detailsv2.0.0

flutter_share

Simple way to share message, links or files from your flutter app for Android and IOS (Enter to see some gifs).

AndroidiOS
30-day downloads
2.8K
Likes
306
Pub points
150

Install package

flutter pub add flutter_share

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Flutter Share is a lightweight Flutter package that enables seamless sharing of messages, links, and files from Android and iOS apps. It provides a simple API to integrate native sharing intents, allowing users to share content through system dialogs. The package supports both text and file sharing, making it ideal for apps needing quick sharing functionality. With minimal setup via pub add, it works across platforms without requiring platform-specific code. The source code is open on GitHub, encouraging transparency and community contributions.

Use cases

  • Sharing links within social media
  • Sending text snippets to messaging apps
  • Exporting files like images or documents
  • Enabling user-generated content sharing
  • Integrating with app's social features

Key features

  • Cross-platform support (Android & iOS)
  • Simple API for sharing text and files
  • Native sharing dialogs
  • Open-source with GitHub repository
  • Minimal configuration required

Suitable for

  • Apps needing basic sharing functionality
  • Social or content-sharing apps
  • File management or productivity tools
  • Developers seeking easy integration
  • Projects prioritizing simplicity and reliability

Considerations

  • Limited to Android and iOS platforms
  • Requires user interaction for sharing
  • No advanced customization options
  • Depends on native OS sharing mechanisms
  • Does not support sharing to specific apps directly

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Share Plugin

pub package

** This plugin was discontinued after the flutter official one add support to files **

A Flutter plugin for IOS and Android providing a simple way to share a message, link or local files.

Features:

  • Share messages and/or link urls.
  • Share local files.

android         ios

Installation

First, add flutter_share as a dependency in your pubspec.yaml file.

iOS

Add if not exists one row to the ios/podfile after target runner:

...

target 'Runner' do
    use_frameworks!

...
Android

If you pretends to use the file share, you need to configure the file provider, this will give access to the files turning possible to share with other applications.

Add to AndroidManifest.xml:

<application>
...
<provider
    android:name="androidx.core.content.FileProvider"
    android:authorities="${applicationId}.provider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/provider_paths"/>
</provider>
</application>

Obs: You can change the android:name if you have an extension of file provider.

Add res/xml/provider_paths.xml:

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="external_files" path="."/>
</paths>

If you want to learn more about file provider you can access:

  • https://developer.android.com/reference/android/support/v4/content/FileProvider
Example

Here is an example flutter app displaying the two shares methods. (I'm using documents_picker just to get a local file you don't need to use.)

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:flutter_share/flutter_share.dart';
import 'package:documents_picker/documents_picker.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  Future<void> share() async {
    await FlutterShare.share(
      title: 'Example share',
      text: 'Example share text',
      linkUrl: 'https://flutter.dev/',
      chooserTitle: 'Example Chooser Title'
    );
  }

  Future<void> shareFile() async {
    List<dynamic> docs = await DocumentsPicker.pickDocuments;
    if (docs == null || docs.isEmpty) return null;

    await FlutterShare.shareFile(
      title: 'Example share',
      text: 'Example share text',
      filePath: docs[0] as String,
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              FlatButton(
                child: Text('Share text and link'),
                onPressed: share,
              ),
              FlatButton(
                child: Text('Share local file'),
                onPressed: shareFile,
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Feedback welcome and Pull Requests are most welcome!

Categories

Source repository

Projects using this package