share_plus_ohos

HarmonyOS (OpenHarmony / HarmonyOS NEXT) system-share implementation for share_plus, backed by the Share Kit system panel (@hms.collaboration.systemShare).

How it works

  • Dart sideSharePlusOhos extends SharePlatform (share_plus_platform_interface). Declared as dartPluginClass with implements: share_plus, so the Flutter tool registers it automatically for ohos builds; no changes to the app-facing share_plus package are needed.
  • Native sideSharePlusOhosPlugin serves the method channel org.tsinbeilabs.share_plus_ohos/share and opens the system share panel:
    Method Behavior
    shareText SharedRecord with PLAIN_TEXT utd + content
    shareUri SharedRecord with HYPERLINK utd + content
    shareFiles one SharedRecord per file (IMAGE/FILE utd + fileUri), optional trailing text record

Usage

Add both packages to your HarmonyOS dependency graph:

dependencies:
  share_plus: ^13.3.0
  share_plus_ohos:
    git:
      url: https://github.com/TsinbeiLabs/share_plus_ohos.git
      ref: main

Register the native plugin in GeneratedPluginRegistrant.ets:

import SharePlusOhosPlugin from 'share_plus_ohos';
// ...
flutterEngine.getPlugins()?.add(new SharePlusOhosPlugin());

Notes & limitations

  • ShareResult.status is reported as ShareResultStatus.unavailable: the Share Kit panel does not report the user's final action.
  • Files are shared by file:// URI from the app sandbox (fileUri.getUriFromPath); the share framework handles temporary read grants for sandbox files.
  • Requires HarmonyOS NEXT with the Share Kit system capability (SystemCapability.Collaboration.SystemShare, API 11+ panel APIs as declared by the SDK; app targets API 24 / HarmonyOS 6.x in Luotopia).

License

Apache-2.0.

Libraries

share_plus_ohos
HarmonyOS system-share implementation for share_plus.