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 side —
SharePlusOhos extends SharePlatform(share_plus_platform_interface). Declared asdartPluginClasswithimplements: share_plus, so the Flutter tool registers it automatically for ohos builds; no changes to the app-facingshare_pluspackage are needed. - Native side —
SharePlusOhosPluginserves the method channelorg.tsinbeilabs.share_plus_ohos/shareand opens the system share panel:Method Behavior shareTextSharedRecordwithPLAIN_TEXTutd +contentshareUriSharedRecordwithHYPERLINKutd +contentshareFilesone SharedRecordper file (IMAGE/FILEutd +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.statusis reported asShareResultStatus.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
- HarmonyOS system-share implementation for
share_plus.