flutter_flutter:基于 Flutter 技术栈的 OpenHarmony 应用开发工具项目

开发者可使用熟悉的 Flutter 技术栈开发 OpenHarmony 应用,复用现有 Flutter 生态资源。该项目是 Flutter SDK 的 OpenHarmony 适配版本,基于 Flutter 官方 3.27.4 版本构建,支持创建、构建、运行等多种开发指令。【此简介由AI生成】

分支46Tags54
文件最后提交记录最后更新时间
Simplify the template for infrastructure requests (#171905) Closes https://github.com/flutter/flutter/issues/165814.10 个月前
更新版权头信息 Signed-off-by: chenzhensheng79 <15118029047@139.com> 1 年前
Branch oh-3.35.7-release update engine.ohos.har.version to a9b33dbee6d141143e287d2e4dcc8c85331cea76 Signed-off-by: gaoyu321 <2376518379@qq.com> 17 天前
Reland "Add a buildtools directory and move third_party/ninja to the project root in order to match the expectations of depot_tools" (#164240) Relands https://github.com/flutter/flutter/pull/163890 and updates the Ninja path used by the engine tool1 年前
新增rebase脚本信息 Signed-off-by: qq_77777 <qishijie3@h-partners.com> 21 天前
fix build error Signed-off-by: zhongning5 <zhongning5@huawei.com> 5 个月前
Reland "Add feature flags to the framework" (#171545) This relands https://github.com/flutter/flutter/pull/168437. The google3 fixes were landed in: https://github.com/flutter/flutter/pull/171547, https://critique.corp.google.com/cl/781275353, https://github.com/flutter/flutter/pull/171933. This PR is split into two commits: 1. d6253794e8982348c5c21cb63e8f6bf785664be6, code from https://github.com/flutter/flutter/pull/168437 without any changes 2. f35d29e4af630d2d4fdb0cda8686b6ff9f77227a, updates the PR to omit obvious types. Original PR description: ## Motivation We'd like to let users opt-in to experimental features so that they can give early feedback while we iterate on the feature. For example: Example feature flags: 1. Android sensitive content: https://github.com/flutter/flutter/pull/158473. When enabled, Flutter will tell Android when the view contains sensitive content like a password. 3. Desktop multi-window. When enabled, Flutter will use child windows to allow things like a context menu to "escape" outside of the current window. ### Use case Users will be able to turn on features by: * **Option 1**: Run flutter config --enable-my-feature. This enables the feature for all projects on the machine * **Option 2**: Add enable-my-feature: true in their pubspec.yaml, under the flutter section. This would enable the for a single project on the machine. Turning on a feature affects _both_ development-time (flutter run) and deployment-time (flutter build x). For example, I can `flutter build windows to create an .exe` with multi-window features enabled. ## How this works This adds a new [runtimeId](https://github.com/flutter/flutter/pull/168437/files#diff-0ded384225f19a4c34d43c7c11f7cb084ff3db947cfa82d8d52fc94c112bb2a7R243-R247) property to the tool's Feature class. If a feature is on and has a runtimeId, its runtimeId will be [stamped into the Dart application as a Dart define](https://github.com/flutter/flutter/pull/168437/files#diff-bd662448bdc2e6f50e47cd3b20b22b41a828561bce65cb4d54ea4f5011cc604eR293-R327). The framework uses this Dart define to [determine which features are enabled](https://github.com/flutter/flutter/pull/168437/files#diff-c8dbd5cd3103bc5be53c4ac5be8bdb9bf73e10cd5d8e4ac34e737fd1f8602d45). ### Multi-window example https://github.com/flutter/flutter/pull/168697 shows how this new feature flag system can be used to add a multi-window feature flag: 1. It adds a new [multi-window feature](https://github.com/flutter/flutter/pull/168697/files#diff-0ded384225f19a4c34d43c7c11f7cb084ff3db947cfa82d8d52fc94c112bb2a7R189-R198) to the Flutter tool. This can be turned on using `flutter config --enable-multi-window or by putting enable-multi-window: true` in an app's .pubspec, under the flutter section. 2. It adds a new [isMultiWindowEnabled](https://github.com/flutter/flutter/pull/168697/files#diff-c8dbd5cd3103bc5be53c4ac5be8bdb9bf73e10cd5d8e4ac34e737fd1f8602d45R7-R11) property to the framework. 4. The Material library can use this new property to determine whether it should create a new window. [Example](https://github.com/flutter/flutter/pull/168697/files#diff-2cbc1634ed6b61d61dfa090e7bfbbb7c60b74c8abc3a28df6f79eee691fd1b73). ## Limitations ### Tool and framework only For now, these feature flags are available only to the Flutter tool and Flutter framework. The flags are not automatically available to the embedder or the engine. For example, embedders need to configure their surfaces differently if Impeller is enabled. This configuration must happen before the Dart isolate is launched. As a result, the framework's feature flags is not a viable solution for this scenario for now. For these kinds of scenarios, we should continue to use platform-specific configuration like the AndroidManifest.xml or Info.plist files. This is a fixable limitation, we just need to invest in this plumbing :) ### Tree shaking Feature flags are not designed to help tree shaking. For example, you cannot conditionally import Dart code depending on the enabled feature flags. Code that is feature flagged off will still be imported into user's apps.10 个月前
fix napi lookupcallbackinformation Signed-off-by: zhong_ning <zhong_ning@hoperun.com> 17 天前
merge 3.35.7-upload into flutter_3.35.7_deps Signed-off-by: zhongning5 <zhongning5@huawei.com> 5 个月前
!1103 merge ohos-run-stale-fix into oh-3.35.7-dev [ohos][3.35] Stop debug packaging after flutter assemble failure Created-by: ZuoYueLiang Commit-by: guoshuyu Merged-by: openharmony_ci Description: ## Why are these changes being made? When an OHOS Flutter app is launched with flutter run -d 127.0.0.1:5555, the Hvigor integration invokes flutter assemble debug_ohos_application before it copies flutter_assets and continues HAP packaging. This change fixes a misleading failure mode in the OHOS debug pipeline: 1. Dart source has already become invalid. 2. flutter assemble actually reports the frontend compile error. 3. The OHOS Hvigor plugin logs that failure but does not stop execution. 4. The plugin continues reusing stale flutter_assets. 5. Hvigor still packages and installs a HAP containing the old kernel_blob.bin. 6. flutter run looks successful, but the device is still running old code. That behavior is dangerous for debugging because it creates a false signal: "latest source failed to compile, but the command still looks green and the app still launches." The fix makes the OHOS Hvigor plugin fail fast when flutter assemble fails, so the build stops before stale flutter_assets can be copied and before any HAP can be installed as if the run had succeeded. ## Test Demo https://gitcode.com/ZuoYueLiang/ohos_run_stale_demo ## Changelog - added - a normalized minimal OHOS repro demo covering: - healthy baseline run - broken Dart run - direct flutter assemble verification - artifact inspection for app.dill, kernel_blob.bin, and HAP - archived before-fix and after-fix evidence under the demo workspace - a consolidated PR draft with embedded raw log excerpts - fixed - the OHOS Hvigor plugin no longer swallows flutter assemble failures - flutter run now fails in :entry:default@FlutterTask when Dart frontend compilation fails - stale kernel_blob.bin is no longer followed by a fake successful HAP build/install in the same failed run - the debug workflow now surfaces the real Dart compile error instead of relaunching old app content - deprecated - none - removed - the old behavior where flutter assemble failure could be logged and then ignored by the OHOS Hvigor plugin - optimized - OHOS debug failure reporting is now aligned with the actual build result, which reduces false-positive successful runs and makes diagnosis faster ## Evidence Summary ### Healthy baseline is still good Before and after the fix, the healthy BUILD_OK_V1 path still works normally. ```text Launching lib/main.dart on 127.0.0.1:5555 in debug mode... start hap build... Running Hvigor task assembleHap... 17.9s ✓ Built build/ohos/hap/entry-default-signed.hap. installing hap. bundleName: com.example.textfield_ohos_repro waiting for a debug connection: http://127.0.0.1:61820/w8zvIXze4-k=/ Execute attach command for bundle: com.example.textfield_ohos_repro Syncing files to device 127.0.0.1:5555... 134ms ``` That confirms the fix does not break the normal OHOS debug path. ### Before the fix: broken Dart still looked successful With source changed to BUILD_BROKEN_V2 and an intentional thisMethodDoesNotExist() frontend error, flutter run still looked like a successful run: ```text Launching lib/main.dart on 127.0.0.1:5555 in debug mode... start hap build... Running Hvigor task assembleHap... 12.2s ✓ Built build/ohos/hap/entry-default-signed.hap. installing hap. bundleName: com.example.textfield_ohos_repro waiting for a debug connection: http://127.0.0.1:51807/vxuyuY9TNko=/ Execute attach command for bundle: com.example.textfield_ohos_repro ``` This is the bug. Broken Dart code should have stopped the run instead of printing a successful HAP build/install path. ### Before the fix: direct assemble already exposed the real error The underlying Flutter assemble step was already failing correctly: ```text lib/main.dart:12:5: Error: The method 'thisMethodDoesNotExist' isn't defined for the type 'DemoApp'. - 'DemoApp' is from 'package:ohos_run_stale_demo/main.dart' ('lib/main.dart'). Try correcting the name to the name of an existing method, or defining a method named 'thisMethodDoesNotExist'. thisMethodDoesNotExist(); ^^^^^^^^^^^^^^^^^^^^^^ Target kernel_snapshot_program failed: Exception ... [ ] exiting with code 1 ``` So the real issue was not "Dart compiled successfully." The real issue was that the failure got swallowed later in the OHOS debug packaging flow. ### Before the fix: artifacts split into new and stale outputs The broken run produced a clear split between app.dill and the packaged OHOS artifacts: ```text == .dart_tool/flutter_build/6773b291f241dc7c20fb56c71639575f/app.dill == mtime=2026-04-20 16:01:52 size=40935192 f896b173eda009fdf38a63c96890ba49bf0cec8150423aa3eb142a549f5540bc .dart_tool/flutter_build/6773b291f241dc7c20fb56c71639575f/app.dill thisMethodDoesNotExist(); 'BUILD_BROKEN_V2', == build/ohos/intermediates/flutter/defaultDebug/flutter_assets/kernel_blob.bin == mtime=2026-04-20 16:00:47 size=40933808 f75735c88d3de706f298fea35e9c202197d6e49e48ae30f2f25ba6ca602c81fa build/ohos/intermediates/flutter/defaultDebug/flutter_assets/kernel_blob.bin 'BUILD_OK_V1', == build/ohos/hap/entry-default-signed.hap == mtime=2026-04-20 16:02:00 size=93776319 15f18fa6025d9379aa53a2aa99f4e6bc50e162a64d3b3298413e623887602dd8 build/ohos/hap/entry-default-signed.hap 'BUILD_OK_V1', ``` This proves the pre-fix failure mode was: 1. app.dill moved forward to broken source and contained the frontend error. 2. kernel_blob.bin stayed stale and still contained BUILD_OK_V1. 3. a newly packaged HAP still embedded the stale kernel blob. In other words, this was a "new app.dill + old kernel_blob.bin + new HAP wrapping old kernel" split-brain packaging problem. ### After the fix: broken Dart fails at FlutterTask After rethrowing the flutter assemble failure in the Hvigor plugin, the same broken source now fails loudly and directly: ```text Launching lib/main.dart on 127.0.0.1:5555 in debug mode... start hap build... Running Hvigor task assembleHap... lib/main.dart:12:5: Error: The method 'thisMethodDoesNotExist' isn't defined for the type 'DemoApp'. - 'DemoApp' is from 'package:ohos_run_stale_demo/main.dart' ('lib/main.dart'). Try correcting the name to the name of an existing method, or defining a method named 'thisMethodDoesNotExist'. thisMethodDoesNotExist(); ^^^^^^^^^^^^^^^^^^^^^^ Target kernel_snapshot_program failed: Exception flutter assemble: Command failed: /Users/guoshuyu/workspace/flutter-work/flutter_flutter/bin/flutter --quiet assemble --no-version-check ... > hvigor ERROR: Failed :entry:default@FlutterTask... > hvigor ERROR: BUILD FAILED in 3 s 708 ms ProcessException: The command failed with exit code 255 ``` Important negative evidence after the fix: ```text there is no: ✓ Built build/ohos/hap/entry-default-signed.hap. there is no: installing hap. bundleName: ... ``` That is the intended behavior. A failed Dart compile should fail the OHOS debug run immediately. ### After the fix: direct assemble still reports the same frontend failure The raw assemble path remains unchanged and still exposes the root error: ```text lib/main.dart:12:5: Error: The method 'thisMethodDoesNotExist' isn't defined for the type 'DemoApp'. - 'DemoApp' is from 'package:ohos_run_stale_demo/main.dart' ('lib/main.dart'). Try correcting the name to the name of an existing method, or defining a method named 'thisMethodDoesNotExist'. thisMethodDoesNotExist(); ^^^^^^^^^^^^^^^^^^^^^^ Target kernel_snapshot_program failed: Exception ... [ ] exiting with code 1 ``` ### After the fix: stale files may still exist, but they are no longer treated as a successful new build After a failed broken run, prior successful outputs can still remain on disk, but they are no longer packaged/installed as part of a fake green run: ```text == .dart_tool/flutter_build/6773b291f241dc7c20fb56c71639575f/app.dill == mtime=2026-04-20 16:15:35 size=40935192 f896b173eda009fdf38a63c96890ba49bf0cec8150423aa3eb142a549f5540bc .dart_tool/flutter_build/6773b291f241dc7c20fb56c71639575f/app.dill thisMethodDoesNotExist(); 'BUILD_BROKEN_V2', == build/ohos/intermediates/flutter/defaultDebug/flutter_assets/kernel_blob.bin == mtime=2026-04-20 16:13:56 size=40933808 f75735c88d3de706f298fea35e9c202197d6e49e48ae30f2f25ba6ca602c81fa build/ohos/intermediates/flutter/defaultDebug/flutter_assets/kernel_blob.bin 'BUILD_OK_V1', == build/ohos/hap/entry-default-signed.hap == mtime=2026-04-20 16:14:09 size=93776318 df2765d9ef7dae0a12b1086bdc2203a7cc1fc04300018c8907aa85975b1fed72 build/ohos/hap/entry-default-signed.hap 'BUILD_OK_V1', ``` The key correction is behavioral: 1. app.dill still reflects the broken new source. 2. old kernel_blob.bin and old successful HAP may still exist on disk. 3. the failed run no longer pretends they are the output of the current build. 4. the failed run no longer installs and relaunches stale app content. ## Root Cause The issue is in the OHOS Hvigor plugin path used by flutter run. Before this change, the plugin wrapped execSync(flutter assemble ...) in a try/catch, logged the error, and then continued execution: 1. run flutter assemble 2. catch the error 3. print the error 4. continue copying flutter_assets 5. continue HAP packaging 6. continue install flow Because the copy step used the existing intermediate output directory, stale kernel_blob.bin from the previous successful build could be reused. The fix changes that behavior to rethrow after logging the flutter assemble failure, which stops the task before stale assets can be reused. ## Implementation The change is localized to: - packages/flutter_tools/hvigor/src/plugin/flutter-hvigor-plugin.ts Updated behavior: ```ts } catch (error) { const message = error instanceof Error ? error.message : String(error) console.error See merge request: openharmony-tpc/flutter_flutter!11031 个月前
Add ReleaseNote and Changelog for 3.35.7-ohos-1.0.1 Signed-off-by: gaoyu321 <2376518379@qq.com> 16 天前
Reland "Add a buildtools directory and move third_party/ninja to the project root in order to match the expectations of depot_tools" (#164240) Relands https://github.com/flutter/flutter/pull/163890 and updates the Ninja path used by the engine tool1 年前
merge 3.35.7-upload into flutter_3.35.7_deps Signed-off-by: zhongning5 <zhongning5@huawei.com> 5 个月前
Merge branch 'oh-3.35.7-dev' into 'oh-3.35.7-release' # Conflicts: # conflict .ci_ohos.yaml # conflict ci/scripts/check_system_info.sh # conflict ci/scripts/prepare_openharmony_sdk.sh # conflict ci/scripts/publish.py24 天前
Add pre-stable support for create on Windows (#51895) Adds initial support for flutter create of apps and plugins. This is derived from the current FDE example app and sample plugin, adding template values where relevant. Since the APIs/tooling/template aren't stable yet, the app template includes a version marker, which will be updated each time there's a breaking change. The build now checks that the template version matches the version known by that version of the tool, and gives a specific error message when there's a mismatch, which improves over the current breaking change experience of hitting whatever build failure the breaking change causes and having to figure out that the problem is that the runner is out of date. It also adds a warning to the create output about the fact that it won't be stable. Plugins don't currently have a version marker since in practice this is not a significant problem for plugins yet the way it is for runners; we can add it later if that changes. Fixes #307046 年前
Remove pubspec.lock files for flutter_tools and widget_preview_scaffold. (#170364) Closes https://github.com/flutter/flutter/issues/170264. I believe these files were _accidentally_ introduced in https://github.com/flutter/flutter/pull/168662, as part of the workspace-ifying of flutter/flutter; these two packages are _not_ part of the workspace, and there is special logic in bin/internal/shared.sh (i.e. the entrypoint to flutter) that expects this file to be updated: https://github.com/flutter/flutter/blob/2d30ce56feb7fe1c71be699024a56482dca61a7e/bin/internal/shared.sh#L131 We can revisit this if the pub team has advice on what to do; for now helps the periodic failures described in https://github.com/flutter/flutter/issues/170264.11 个月前
fix(ios): correctly inherits the handle color from the theme (#166507) ## Description If specified, apply the selectionHandleColor from the theme to the iOS handle. ## Related Issue - https://github.com/flutter/flutter/issues/166506 #### Minimum reproducible example ```dart import 'package:flutter/material.dart'; void main() { runApp( MaterialApp( theme: ThemeData( textSelectionTheme: TextSelectionThemeData( selectionHandleColor: Colors.yellow, ), ), home: Scaffold(body: Center(child: TextField())), ), ); } ``` #### Visual Reference | Previous | Now | |--------|--------| | <img src="https://github.com/user-attachments/assets/91e49e07-ef4a-47ab-b65a-b147f441f252" /> | <img src="https://github.com/user-attachments/assets/fd27d602-6f7c-4d7d-a310-97f417bde819" /> | ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with ///). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.1 年前
Create changelog entry for flutter 3.35.7 (#177334) Changelog entry onlyl7 个月前
Add ReleaseNote and Changelog for 3.35.7-ohos-1.0.1 Signed-off-by: gaoyu321 <2376518379@qq.com> 16 天前
Add android-reviewers to CODEOWNERS (#170157) Mirror GitHub team-android labeller to android-reviewer CODEOWNERS so that group is automatically put on Android PRs. Add tools android and gradle files. Also add the Android embedder. You can run git ls-files packages/flutter_tools/**/*android* etc to see which files are included. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with ///). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md11 个月前
Update old wiki links (#149544) Part of https://github.com/flutter/flutter/issues/145009 Finishes updating links in the repo that pointed to the old wiki1 年前
Fix link to engine docs in CONTRIBUTING.md (#161401) 1 年前
Bump dart revision and add changelog. (#174887) Changelog and dart revision bump for 3.35.3 Dart revision is [3.9.2 (stable)](https://github.com/dart-lang/sdk/commit/a29e08c72e2ce21813c1edf50cbcdfcac7a7acdd)8 个月前
update commit id Signed-off-by: zhongning5 <zhongning5@huawei.com> 5 个月前
License update (#45373) * Update project.pbxproj files to say Flutter rather than Chromium Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright. * Update the copyright notice checker to require a standard notice on all files * Update copyrights on Dart files. (This was a mechanical commit.) * Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine. Some were already marked "The Flutter Authors", not clear why. Their dates have been normalized. Some were missing the blank line after the license. Some were randomly different in trivial ways for no apparent reason (e.g. missing the trailing period). * Clean up the copyrights in non-Dart files. (Manual edits.) Also, make sure templates don't have copyrights. * Fix some more ORGANIZATIONNAMEs 6 年前
更新版权头信息 Signed-off-by: chenzhensheng79 <15118029047@139.com> 1 年前
更新版权头信息 Signed-off-by: chenzhensheng79 <15118029047@139.com> 1 年前
Rename patent file (#38686) Rename this file to work around a limitation of the GitHub license detection tool, to ensure the repo is correctly tagged as BSD licensed6 年前
Adaptation of Flutter 3.22 for the OHOS platform 1 年前
update README.OpenSource for 3.35.7 Signed-off-by: zhongning5 <zhongning5@huawei.com> 5 个月前
更新README Signed-off-by: wenwenyang <707997111@qq.com> 1 个月前
更新README Signed-off-by: wenwenyang <707997111@qq.com> 1 个月前
[CP beta] Use LLDB as the default debugging method for iOS 17+ and Xcode 26+ (#173443) (#173472) Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request. ### Issue Link: Part 2 of https://github.com/flutter/flutter/issues/144218 ### Changelog Description: Explain this cherry pick in one line that is accessible to most Flutter developers. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples Implementation of a future fix to allow Xcode 26 to flutter run twice in a row. ### Impact Description: What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch) Flutter developers running Xcode 26 can flutter run to a tethered iOS device once. However subsequent flutter run attempts are likely to fail. ### Workaround: Is there a workaround for this issue? Quitting and reopening Xcode. ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? ### Validation Steps: What are the steps to validate that this fix works? Create a flutter project and run flutter run twice in a row with a physical iOS 17+ device and Xcode 26.9 个月前
Remove outdated ignores (#162773) Powered by the new and amazing unnecessary_ignore lint. We're not enabling this lint by default because being able to temporarily use ignores that don't ignore anything is a powerful tool to enable migrations. We should turn this lint on locally periodically, though, and clean up all outdated ignores.1 年前
Move snippets package back into flutter repo (#147690) ## Description This moves the snippets package back into the Flutter repo so that API documentation generation can happen without the use of dart pub global run because pub run doesn't handle concurrency well. The change modifies the dartdoc building process to include building an executable from the snippets tool and installing that in the cache directory for use during docs generation. The snippets tool will reside in dev/snippets, where it originally resided before being moved to https://github.com/flutter/assets-for-api-docs. The snippets code itself is unchanged from the code that is in https://github.com/flutter/assets-for-api-docs/packages/snippets. ## Related Issues - https://github.com/flutter/flutter/issues/144408 - https://github.com/flutter/flutter/issues/147609 - https://github.com/flutter/flutter/pull/147645 ## Tests - Added snippets tests to the overall testing build.2 年前
License update (#45373) * Update project.pbxproj files to say Flutter rather than Chromium Also, the templates now have an empty organization so that we don't cause people to give their apps a Flutter copyright. * Update the copyright notice checker to require a standard notice on all files * Update copyrights on Dart files. (This was a mechanical commit.) * Fix weird license headers on Dart files that deviate from our conventions; relicense Shrine. Some were already marked "The Flutter Authors", not clear why. Their dates have been normalized. Some were missing the blank line after the license. Some were randomly different in trivial ways for no apparent reason (e.g. missing the trailing period). * Clean up the copyrights in non-Dart files. (Manual edits.) Also, make sure templates don't have copyrights. * Fix some more ORGANIZATIONNAMEs 6 年前
Roll pub packages (#171415) This PR was generated by flutter update-packages --force-upgrade.10 个月前
Bump Dart to 3.8 and reformat (#171703) Bumps the Dart version to 3.8 across the repo (excluding engine/src/flutter/third_party) and applies formatting updates from Dart 3.8. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with ///). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md10 个月前

Flutter SDK & Engine 仓库

仓库说明

本仓库是 Flutter SDKFlutter EngineOpenHarmony 适配版本,由 OpenHarmony-Flutter 团队维护。开发者可使用熟悉的 Flutter 技术栈开发 OpenHarmony 应用,也可基于本仓库源码构建支持 OpenHarmony 的 Flutter Engine。

该版本分支基于 Flutter 官方社区 3.35.7 版本构建。

版本规划与分支策略请参见:Flutter OH 版本规划与分支策略

仓库结构

Flutter 3.35.7 版本,Engine 源码已合并到仓库的 engine/ 目录下,无需再单独克隆 Engine 仓库。

flutter_flutter/                 # 仓库根目录
├── packages/                    # Flutter SDK 框架代码
│   ├── flutter/                 # Flutter 框架核心
│   ├── flutter_tools/           # Flutter CLI 工具
│   └── ...
├── engine/                      # Flutter Engine 引擎代码
└── ...

开发指南

应用开发

构建Engine

升级指导

请参见:Flutter OH 版本升级指导

支持指令

已适配 OpenHarmony 开发的指令列表:

指令名称 指令描述 使用说明
doctor 环境检测 flutter doctor
config 环境配置 flutter config --<key> <value>
create 创建新项目 flutter create --platforms [ohos,android,ios] --org <org> <appName>
create 创建module模板 flutter create -t module <module_name>
create 创建plugin模板 flutter create -t plugin --platforms [ohos,android,ios] <plugin_name>
create 创建plugin_ffi模板 flutter create -t plugin_ffi --platforms [ohos,android,ios] <plugin_name>
devices 已连接设备查找 flutter devices
install 应用安装 flutter install -t <deviceId> <hap文件路径>
assemble 资源打包 flutter assemble
build 测试应用构建 flutter build hap --debug [--target-platform ohos-arm64] [--local-engine=<兼容ohos的debug engine产物路径>]
build 正式应用构建 flutter build hap --release [--target-platform ohos-arm64] [--local-engine=<兼容ohos的release engine产物路径>]
run 应用运行 flutter run [--local-engine=<兼容ohos的engine产物路径>]
attach 调试模式 flutter attach
screenshot 截屏 flutter screenshot
pub 获取依赖 flutter pub get
clean 清除项目依赖 flutter clean
cache 清除全局缓存数据 flutter pub cache clean

常见问题

  1. 切换FLUTTER_STORAGE_BASE_URL后需删除<flutter>/bin/cache 目录,并在项目中执行flutter clean后再运行

  2. 若出现报错:The SDK license agreement is not accepted,参考执行以下命令后再次编译:

    ./ohsdkmgr install ets:9 js:9 native:9 previewer:9 toolchains:9 --sdk-directory='/home/xc/code/sdk/ohos-sdk/' --accept-license
    
  3. 如果你使用的是DevEco Studio的Beta版本,编译工程时遇到"must have required property 'compatibleSdkVersion', location: demo/ohos/build-profile.json5:17:11"错误。请参考《DevEco Studio配置文件》中的 工程级build-profile.json5文件 → products 配置 compatibleSdkVersion

  4. 若提示安装报错:fail to verify pkcs7 file 请执行指令

    hdc shell param set persist.bms.ohCert.verify true
    
  5. linux虚拟机通过hdc无法直接发现OpenHarmony设备

    解决方案:在windows宿主机中,开启hdc server,具体指令如下:

    hdc kill
    hdc -s serverIP:8710 -m
    

    在linux中配置环境变量:

    HDC_SERVER=<serverIP>
    HDC_SERVER_PORT=8710
    

    配置完成后flutter sdk可以通过hdc server完成设备连接,也可参考官方指导

  6. 构建Hap任务时报错:Error: The hvigor depends on the npmrc file. Configure the npmrc file first.

    请在用户目录~下创建文件.npmrc,该配置也可参考DevEco Studio官方文档,编辑内容如下:

    registry=https://repo.huaweicloud.com/repository/npm/
    @ohos:registry=https://repo.harmonyos.com/npm/
    
  7. 查日志时,存在日志丢失现象。 解决方案:关闭全局日志,只打开自己领域的日志

    # 步骤一:关闭所有领域的日志打印(部分特殊日志无法关闭)
    hdc shell hilog -b X
    # 步骤二:只打开自己领域的日志
    hdc shell hilog <level> -D <domain>
    # 其中<level>为日志打印的级别:D/I/W/E/F,<domain>为Tag前面的数字
    # 举例:
    # 打印A00000/XComFlutterOHOS_Native的日志,需要设置hdc shell hilog -b D -D A00000
    # 注:上面的设置在机器重启后会失效,如果要继续使用,需要重新设置。
    
  8. 若Api11 Beta1版本的机器上无法启动debug签名的应用,可以通过将签名换成正式签名,或在手机端打开开发者模式解决(步骤:设置->通用->开发者模式)

  9. 如果报Invalid CEN header (invalid zip64 extra data field size)异常,请更换Jdk版本,参见JDK-8313765

  10. 运行debug版本的flutter应用用到鸿蒙设备后报错(release和profile版本正常)

    1. 报错信息: Error while initializing the Dart VM: Wrong full snapshot version, expected '8af474944053df1f0a3be6e6165fa7cf' found 'adb4292f3ec25074ca70abcd2d5c7251'
    2. 解决方案: 依次执行以下操作
      1. 设置环境变量 export FLUTTER_STORAGE_BASE_URL=https://flutter-ohos.obs.cn-south-1.myhuaweicloud.com
      2. 删除 /bin/cache 目录下的缓存
      3. 执行 flutter clean,清除项目编译缓存
      4. 运行 flutter run -d $DEVICE --debug
    3. 补充信息: 运行android或ios出现类似错误,也可以尝试还原环境变量 FLUTTER_STORAGE_BASE_URL ,清除缓存后重新运行。
  11. Beta2版本的ROM更新后,不再支持申请有执行权限的匿名内存,导致debug运行闪退。

    1. 解决方案:更新 flutter_flutter 到 a44b8a6d (2024-07-25) 之后的版本。

    2. 关键日志:

          #20 at attachToNative (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi.ets:78:32)
          #21 at attachToNapi (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:144:5)
          #22 at init (oh_modules/.ohpm/@ohos+flutter_ohos@g8zhdaqwu8gotysbmqcstpfpcpy=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine.ets:133:7)
      
  12. 构建Hap命令直接执行flutter build hap即可,不再需要--local-engine参数,直接从云端获取编译产物。

  13. 配置环境完成后执行 flutter 命令 出现闪退。

    1. 解决方案:windows环境中添加git环境变量配置。

      export PATH=<git path>/cmd:$PATH
      
  14. 执行flutter pub cache clean 正常 执行flutter clean 报错,按照报错信息执行 update 命令也没有效果。

    1. 解决方案:通过注释掉 build.json5 文件中的配置规避。

    2. 报错信息:

       #Parse ohos module. json5 error: Exception: Can not found module.json5 at
       #D:\pub_cache\git\flutter_packages-b00939bb44d018f0710d1b080d91dcf4c34ed06\packages\video_player\video_player_ohos\ohossrc\main\module.json5.
       #You need to update the Flutter plugin project structure.
       #See
       #https://gitcode.com/openharmony-tpc/flutter_samples/blob/master/ohos/docs/09_specifications/update-flutter-plugin-structure.md
      
  15. 执行flutter build hap 时遇到路径校验报错。

    1. 解决方案:

      • 打开 deveco 安装路径 D:\DevEco Studio\tools\hvigor\hvigor-ohos-plugin\res\schemas 下的 ohos-project-build-profile-schema.json文件。
      • 在该文件中找到包含:"pattern": "^(\./|\.\./)[\s\S]+$"的行,并删除此行。
    2. 报错信息:

       #hvigor  ERROR: Schema validate failed.
       #        Detail: Please check the following fields.
       #instancePath: 'modules[1].scrPath',
       #keyword: 'pattern'
       #params: { pattern:'^(\\./|\\.\\./)[\\s\\S]+$' },
       #message: 'must match pattern "^(\\./|\\.\\./)[\\s\\S]+$"',
       #location: 'D:/work/videoplayerdemo/video_cannot_stop_at_background/ohos/build-profile.json:42:146'
      
  16. 执行flutter build hap 报错。

    1. 解决方案:打开 deveco 安装路径 D:\DevEco Studio\tools\hvigor\hvigor-ohos-plugin\src\model\module 下的 core-module-model-impl.js, 修改 findBelongProjectPath 方法(需要管理员权限,可另存为后替换)

       findBelongProjectPath(e) {
         if (e === path_1.default.dirname(e)) {
            return this.parentProject.getProjectDir()
         }
       }
      
    2. 报错信息:

      # hvigor  ERROR: Cannot find belonging project path for module at D:\.
      # hvigor  ERROR:  BUILD FAILED in 2s 556ms.
      #Running Hvigor task assembleHap...
      #Oops; flutter has exited unexpectedly: "ProcessException: The command failed
      #  <Command: hvigorw --mode module -p module=video_player_ohos@default -p product=default assmbleHar --no-daemon"
      #A crash report has been written to D:\work\videoplayerdemo\video_cannot_stop_at_background\flutter_03.log.
      
  17. DevEco-Studio(5.0.3.600 Beta3),windows版本编译flutter应用报错

    1. 解决方案:更新 flutter_flutter 到 c6fbac2b (2024-08-09) 之后的版本。

    2. 关键日志:

      hvigor ERROR: Schema validate failed.
      	Detail: Please check the following fields.
      	{
      		instancePath: 'modules[2].srcPath',
      		keyword: 'pattern',
      		params: { pattern: '^(\\./|\\.\\./)[\\s\\S]+$' },
      		message: 'must match pattern "^(\\./|\\.\\./)[\\s\\S]+$"',
      	}
      
  18. 在.ohos的项目执行flutter clean 报错,然后再执行flutter pub get也报错。

    1. 解决方案:删除.ohos文件夹,重新flutter pub get 即可

    2. 报错信息:

         Oops; flutter has exited unexpectedly: "PathNotFoundException: Cannot open file, path = 'D:\code\.ohos\build-profile.json5' (OS Error: 系统找不到指定的文件。,error = 2)".
         A crash report has been written to D:\code\flutter_01.log.
      
  19. 模拟器执行时发生白屏、崩溃等现象。

    1. 模拟器只支持Mac(arm64), 还不支持Mac(x86)和Windows
    2. 模拟器暂不支持vulkan,请尝试构建步骤2.1,关闭impeller后重试
  20. flutter profile模式下编译或运行失败

    1. 请在ohos项目build_profile.json5中添加buildModeSet字段,可参考complex_layout

    2. 报错信息:

      hvigor ERROR: Build mode 'profile' used in command line is not declared in buildModeSet in /xxx/example/ohos/build-profile.json5.
      

更多FAQ

贡献指南

如果您想为 Flutter-OH 贡献代码,请参考 Flutter-OH 代码合入流程 了解详细的贡献步骤和规范。

问题交流

项目介绍

开发者可使用熟悉的 Flutter 技术栈开发 OpenHarmony 应用,复用现有 Flutter 生态资源。该项目是 Flutter SDK 的 OpenHarmony 适配版本,基于 Flutter 官方 3.27.4 版本构建,支持创建、构建、运行等多种开发指令。【此简介由AI生成】

定制我的领域

下载使用量

0

项目总下载次数(含Clone、Pull、 zip 包及 release 下载),每日凌晨更新

语言类型

Dart98.63%
C++0.23%
Objective-C0.15%
CMake0.14%
Java0.14%