share static method

Future<void> share(
  1. String text,
  2. {String subject,
  3. Rect sharePositionOrigin}
)

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. It has no effect on non-iPads.

May throw PlatformException or FormatException from MethodChannel.

Implementation

static Future<void> share(
  String text, {
  String subject,
  Rect sharePositionOrigin,
}) {
  assert(text != null);
  assert(text.isNotEmpty);
  final Map<String, dynamic> params = <String, dynamic>{
    'text': text,
    'subject': subject,
  };

  if (sharePositionOrigin != null) {
    params['originX'] = sharePositionOrigin.left;
    params['originY'] = sharePositionOrigin.top;
    params['originWidth'] = sharePositionOrigin.width;
    params['originHeight'] = sharePositionOrigin.height;
  }

  return channel.invokeMethod<void>('share', params);
}