share static method
Summons the platform's share sheet to share text.
Wraps the platform's native share dialog. Can share a text and/or a URL.
It uses the ACTION_SEND
Intent on Android and UIActivityViewController
on iOS.
The optional subject
parameter can be used to populate a subject if the
user chooses to send an email.
The optional sharePositionOrigin
parameter can be used to specify a global
origin rect for the share sheet to popover from on iPads and Macs. It has no effect
on other devices.
May throw PlatformException
or FormatException
from MethodChannel.
ShareResult
provides feedback on how the user
interacted with the share-sheet.
To avoid deadlocks on Android, any new call to share when there is a call pending, will cause the previous call to return a ShareResult.unavailable.
Because IOS, Android and macOS provide different feedback on share-sheet interaction, a result on IOS will be more specific than on Android or macOS. While on IOS the selected action can inform its caller that it was completed or dismissed midway (actions are free to return whatever they want), Android and macOS only record if the user selected an action or outright dismissed the share-sheet. It is not guaranteed that the user actually shared something.
Providing result is only supported on Android, iOS and macOS.
Will gracefully fall back to the non result variant if not implemented for the current environment and return ShareResult.unavailable.
Implementation
static Future<ShareResult> share(
String text, {
String? subject,
Rect? sharePositionOrigin,
}) async {
assert(text.isNotEmpty);
return _platform.share(
text,
subject: subject,
sharePositionOrigin: sharePositionOrigin,
);
}