
很多开发者反馈缺少 Flutter-OH(Flutter for OpenHarmony)的实战案例,导致学习和开发时无从下手。今天给大家重点推荐 AtomGit 平台上的flutter_samples仓库——该仓库专门补充了 OpenHarmony 平台的 Flutter 示例代码,覆盖从基础功能到实战场景的各类案例,是学习 Flutter-OH 的绝佳资源!
这类示例可直接参考落地,覆盖典型业务场景:
flutter_music_player:音乐播放器(支持自动播放、进度条拖拽等核心功能)flutter_smart_agriculture:智慧农场完整实战案例testchat:聊天场景交互 demo覆盖 Flutter-OH 核心基础能力,适合新手快速上手:
仓库名 | 依赖路径 | 描述 |
|---|---|---|
flutter_music_player[1] | flutter_music_player | 本示例展示了一个音乐播放器模型,具有自动播放、拖拽进度条等功能 |
flutter_smart_agriculture[2] | flutter_smart_agriculture | 智慧农场 |
async_test[3] | ohos/async_test | 异步调用 demo |
channel_demo[4] | ohos/channel_demo | 通道测试 demo,可查看 EventChannel/MethodChannel/BasicMessageChannel 方法的返回值 |
clock_test[5] | ohos/clock_test | 计时器 demo,可计时,查看历史计时记录和一些详细数据 |
dio_test[6] | ohos/dio_test | 测试 demo 合集 |
event_bus_test[7] | ohos/event_bus_test | 事件驱动 demo |
flutter_page_sample1[8] | ohos/flutter_page_sample1 | route 路由页面跳转 demo |
flutter_page_sample2[9] | ohos/flutter_page_sample2 | FlutterEntry 的使用示例 |
multiple_flutters_ohos[10] | add_to_app/multiple_flutters/multiple_flutters_ohos | FlutterEngineGroup 多引擎使用示例,可监听生命周期 |
flutter_svg_test[11] | ohos/flutter_svg_test | svg 图片 demo |
http_parser_test[12] | ohos/http_parser_test | http 解析 demo |
http_test[13] | ohos/http_test | http 网页请求 demo |
logging_test[14] | ohos/logging_test | 日志记录 demo |
path_drawing_test[15] | ohos/path_drawing_test | 路径绘制 demo |
pictures_provider_demo[16] | ohos/pictures_provider_demo | 获取图片 demo |
platform_test[17] | ohos/platform_test | 平台调用 demo |
platformchannel_demo[18] | ohos/platformchannel_demo | 平台多项功能接口测试 demo |
rxdart_test[19] | ohos/rxdart_test | rxdart demo,提供了一系列用于处理异步事件和数据流的工具 |
string_scanner_test[20] | ohos/string_scanner_test | 字符扫描 demo |
testcamera[21] | ohos/testcamera | 相机调用 demo |
testchat[22] | ohos/testchat | 聊天场景 demo |
testpicture[23] | ohos/testpicture | 图片展示 demo |
tuple_test[24] | ohos/tuple_test | tuple demo,测试元组类型生产的参数 |
uuid_test[25] | ohos/uuid_test | uuid demo |
vector_math_test[26] | ohos/vector_math_test | 向量匹配 demo |
localtion_demo[27] | ohos/localtion_demo | 获取定位 demo |
针对 Flutter-OH 高阶能力,适合有基础的开发者深挖:
multiple_flutters_ohos:FlutterEngineGroup 多引擎使用(支持生命周期监听)platform_test/platformchannel_demo:OpenHarmony 平台接口调用、多功能接口测试rxdart_test:异步事件/数据流处理工具(rxdart)实战path_drawing_test/vector_math_test:路径绘制、向量计算底层能力演示http_parser_test/string_scanner_test:HTTP 解析、字符扫描底层逻辑测试先下载适配 OpenHarmony 的 Flutter SDK 并完成环境配置,参考官方指引: https://atomgit.com/openharmony-sig/flutter_flutter/blob/master/README.md
不同分支适配不同场景,按需选择:
分支名称 | 生命周期状态 | 使用场景说明 |
|---|---|---|
oh-3.35.7-dev | 技术预览分支 | 功能最新,适合学习研究(非生产环境) |
oh-3.27.0-release | 版本发布分支 | 稳定可靠,适合项目开发(生产环境首选) |
3.22.0-ohos-release | 版本发布分支 | 低版本兼容,适合需适配旧版 OpenHarmony 的开发场景 |
dev/3.22.0-ohos 等 | 主干开发分支 | 技术演进基线,适合跟踪 Flutter-OH 最新适配进展(非生产推荐) |
✨ 核心推荐:学习用oh-3.35.7-dev,项目开发用oh-3.27.0-release。
进入对应示例目录(如flutter_music_player),执行以下命令即可运行:
flutter run
flutter_samples是学习 Flutter-OH 的优质资源,覆盖从基础到进阶的全场景示例,解决了“无实战案例”的核心痛点;oh-3.35.7-dev分支,项目开发选择oh-3.27.0-release分支保证稳定性;欢迎大家下载仓库代码学习,也期待大家参与贡献,一起完善 Flutter-OH 生态!
的联系方式,一起交个朋友!未来也会推出更多新技术的分享
参考资料
[1]
flutter_music_player: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/flutter_music_player
[2]
flutter_smart_agriculture: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/flutter_smart_agriculture
[3]
async_test: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/async_test
[4]
channel_demo: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/channel_demo
[5]
clock_test: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/clock_test
[6]
dio_test: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/dio_test
[7]
event_bus_test: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/event_bus_test
[8]
flutter_page_sample1: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/flutter_page_sample1
[9]
flutter_page_sample2: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/flutter_page_sample2
[10]
multiple_flutters_ohos: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/add_to_app/multiple_flutters
[11]
flutter_svg_test: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/flutter_svg_test
[12]
http_parser_test: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/http_parser_test
[13]
http_test: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/http_test
[14]
logging_test: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/logging_test
[15]
path_drawing_test: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/path_drawing_test
[16]
pictures_provider_demo: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/pictures_provider_demo
[17]
platform_test: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/platform_test
[18]
platformchannel_demo: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/platformchannel_demo
[19]
rxdart_test: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/rxdart_test
[20]
string_scanner_test: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/string_scanner_test
[21]
testcamera: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/testcamera
[22]
testchat: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/testchat
[23]
testpicture: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/testpicture
[24]
tuple_test: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/tuple_test
[25]
uuid_test: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/uuid_test
[26]
vector_math_test: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/vector_math_test
[27]
localtion_demo: https://atomgit.com/openharmony-tpc/flutter_samples/tree/master/ohos/localtion_demo