shareText function

Future<void> shareText(
  1. String text, {
  2. BuildContext? sharePositionContext,
})

One shared share pipeline used by every call site in the app — text-only (e.g. inviting friends) or with a captured screenshot (e.g. a level result). Don't create a separate share function/plugin call elsewhere.

Pass sharePositionContext (typically the widget that triggered the share) so the share sheet has an anchor on iPad — see _sharePositionOriginOf.

Implementation

Future<void> shareText(String text, {BuildContext? sharePositionContext}) {
  return SharePlus.instance.share(
    ShareParams(
      text: text,
      sharePositionOrigin: _sharePositionOriginOf(sharePositionContext),
    ),
  );
}