lollipopkit / lollipopkit/flutter_server_box
feat: HarmonyOS/OHOS platform support — 移植完成,征求合入意见
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 8.7k
- Forks
- 558
- Avg merge
- 4h 31m
- Merged PRs (30d)
- 129
Description
feat: HarmonyOS/OHOS platform support — 移植完成,征求合入意见
背景
我已将 Server Box 移植到华为鸿蒙(OpenHarmony / HarmonyOS NEXT),应用可在 OHOS 设备上正常运行。完整的踩坑记录已整理成专栏:
- 📝 移植记录:https://www.bilibili.com/opus/1239215970340306953
- 🎥 运行视频:https://www.bilibili.com/video/BV1u48B6PEyW
环境:Flutter SDK 3.41.10-ohos-1.0.0(华为 fork,Dart 3.11.5)/ OpenHarmony 6.1.1.120 (API 24, aarch64)
想征求一下您是否愿意合入 OHOS 平台支持,以及期望的提交形式——因为改动涉及面较广,想先沟通再整理 PR,避免白做。
改动范围
1. OHOS 平台目录(ohos/)
EntryAbility.ets:注册path_provider/shared_preferences/flutter_secure_storage三个 MethodChannel(OHOS 引擎不自动注册 Android/iOS 插件)shared_preferences/flutter_secure_storage:文件持久化实现(非内存 Map,重启不丢数据)- 预编译
libsqlite3.so(SQLite3MultipleCiphers,OHOS 无系统 SQLite) - hvigor 构建配置、资源、测试用例
- 平板/横屏适配(
module.json5)
2. Rust FFI 交叉编译
- OHOS target
aarch64-unknown-linux-ohos(Tier 3,需 nightly +-Z build-std) native_toolchain_rust:target 映射 + 解除 nightly 禁令- 链接器 wrapper(OHOS
ld.lld不兼容 GNU ld 部分选项) flutter_pty的 C 代码绕过 CBuilder 直接调用 OHOS clang
3. 第三方库 OHOS 适配(pub cache 补丁)
| 库 | 改动 |
|---|---|
responsive_framework |
switch 补 TargetPlatform.ohos 分支 |
flutter_math_fork |
selectable.dart / line_editable.dart 同上 |
flutter_secure_storage |
复用 AndroidOptions 作 fallback |
sqlite3 |
load_library.dart 加 OHOS 分支 DynamicLibrary.open('libsqlite3.so') |
4. fl_lib 的 OHOS 适配
TargetPlatform.ohos相关处理- Flutter 3.41 API 变更适配(
SizeTransition.alignment→axisAlignment、sqlite3 close()→dispose()、onReorderItem→onReorder等)
需要沟通的点
- 是否接受 OHOS 作为第六个平台? 项目目前支持 Android/iOS/macOS/Linux/Windows。
- 提交形式:改动涉及
fl_lib(需单独向 lollipopkit/fl_lib 提 PR)、若干第三方库的 OHOS 补丁(提 PR 到上游库 or fork)、以及本仓库的ohos/目录。您希望怎么拆分? - 第三方库补丁:pub cache 补丁不持久,正式做法是
dependency_overrides指向 fork 或向上游库提 PR。您倾向哪种? - 依赖版本:为配合华为 fork 的 Flutter 3.41,我本地降级了
drift_dev/freezed/riverpod_generator等。这部分不会进 PR,仅说明背景。
当前状态
移植已完成,应用正常启动(服务器列表、SSH 终端、SFTP、Docker 等功能可用),重启不白屏。如果您有意合入,我会按您的要求整理成干净的 PR。
期待您的意见 🙌
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the proposed ohos/ directory, EntryAbility.ets, module.json5, native_toolchain_rust, and the listed fl_lib and third-party changes. First determine whether OHOS is accepted and how the repository, fl_lib, and dependency patches should be split; done means those decisions are made and the completed migration is organized into maintainable PRs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter, rust
- Domain
- build-system, mobile-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100