Share: Flutter Plugin for Easy Content Sharing

Published on by Flutter News Hub

Share: Flutter Plugin for Easy Content Sharing

The Share plugin empowers Flutter apps to effortlessly share content via the platform's share dialog. This open-source plugin seamlessly integrates with Android's ACTION_SEND Intent and iOS's UIActivityViewController to facilitate content sharing.

Implementation

To leverage the Share plugin in your Flutter project:

  1. Add share as a dependency in your pubspec.yaml file:
dependencies:
  share: ^latest_version
  1. Import the library:
import 'package:share/share.dart';

Sharing Content

To share content, invoke the static share method:

Share.share('Check out my website: https://example.com');

Optionally, specify a subject for email sharing:

Share.share('Check out my website: https://example.com', subject: 'Look what I made!');

Sharing Multiple Files

To share multiple files, use the shareFiles method:

Share.shareFiles(['$/image.jpg'], text: 'Great picture');
Share.shareFiles(['$/image1.jpg', '$/image2.jpg']);

Deprecation Notice

This plugin is deprecated and replaced by its successor, the Flutter Community Plus Plugins version, share_plus. No further updates are planned for this version, and migration to share_plus is strongly encouraged. Critical fixes, such as security patches, will be provided until the end of 2021, after which the package will be marked as discontinued.

Flutter News Hub