share_link

Creator: coderz1093

Last updated:

Add to Cart

Description:

share link

share_link #

Share links with UTM targeting parameters and feedback on the user-selected app.
This library allows sharing of urls using the platform-standard UI via OS integration. UTM targeting parameters utm_source and utm_medium are added in accordance to the sharing target the user selected. For example, if the user shares a link via WhatsApp, the utm_source will be set to "whatsapp" and the utm_medium to "social". If the user shares the link via email, the utm_source will be set to "mail" and the utm_medium to "email".
After a link was shared by the user (or not), this library provides feedback of the chosen target app. You may, for example, use this for analytics or to thank a user for sharing.
Android #
On Android an IntentChooser is used to share the link. This presents the OS-standard sharing bottom sheet. Target-specific links with source/medium are supported for several well-known applications, with a fallback based on the target app's package name.

On Android 10 (API level 29) and later the share targets might show up multiple times in the share sheet, due to platform limitations.
iOS #
On iOS an UIActivityViewController is used to share the link. This presents the sharing bottom sheet (iPhone) or popover (iPad). Target-specific links with source/medium are supported for several well-known applications, with a fallback based on the target app's bundle identifier.

The shareOrigin parameter is ignored on iPhone and required on iPad, for correct placement of the popover. See the example app for a demonstration and helper method.
MacOS #
On MacOS an NSSharingServicePicker is used to share the link. This presents a popover menu with available services. Target-specific links are unsupported, but the user-chosen app is still reported back.

To ensure the popover is placed correctly, you are required to set the shareOrigin parameter.
Web #
On web it attempts to use the Web Share API if available, typically on mobile. If not, it falls back to a simple window.open call with a mailto: link that contains the shared url. The latter method will add utm_source=mail&utm_medium=email parameters to the url.
Installation #
Add to your pubspec.yaml file:
dependencies:
share_link: ^1.0.0
copied to clipboard
Import the library and call shareUri:
import 'package:share_link/share_link.dart';

final result = await LinkShare().shareUri(Uri.parse("https://some_link"));
copied to clipboard
Limitations #
Platform restrictions apply, especially on Android. Feedback on the chosen app is only available since API level 22 (Android 5). On API level 29 (Android 10) and later the share sheet may contain duplicate share targets.
Sharing of files, images or general text is unsupported. This use-case is already greatly covered by the official, community-supported share_plus package.
Limiting sharing to a specific (social media) app is currently unsupported.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.