开发者可通过本项目在 Flutter 应用中无缝集成常用插件,最小化业务改动获得完整 OpenHarmony 原生能力支持。项目基于 Flutter 社区官方插件库扩展,新增对 OpenHarmony 平台的兼容适配,提供多个已适配插件及使用示例。【此简介由AI生成】
Access rate limit exceeded. Please log in to continue.
Flutter Packages
Introduction
This repository is an extension of the Flutter community’s official plugin library ([flutter/packages](vscode-file://vscode-app/e:/Microsoft VS Code/resources/app/out/vs/code/electron-browser/workbench/workbench.html)), adding compatibility and adaptation for the OpenHarmony platform. With this repository, developers can seamlessly integrate commonly used plugins into Flutter applications and gain full support for OpenHarmony native capabilities with minimal business changes.
OpenHarmony Compatible Packages
OpenHarmony Compatible Third-Party Libraries
For third-party library issues, please submit an issue to the corresponding repository. For third-party library adaptation requests, please submit an issue to the CPF-Flutter organization.
Contribution Guidelines
This repository employs a multi-branch management strategy. Each third-party library version maintains dedicated dev and release branches.
| Branch Type | Naming Convention |
|---|---|
| Dev Branch | br_<library-name>-v<version>_ohos_dev |
| Release Branch | br_<library-name>-v<version>_ohos |
When contributing code, please adhere to the following process:
-
Identify the Target Branch: Locate the appropriate dev branch for the third-party library and version you intend to modify.
-
Develop from the Dev Branch: Fork the repository and create your feature branch from the corresponding dev branch.
-
Submit Your Pull Request: Open a pull request targeting the dev branch of the respective library version.
Important: Release branches are designated for stable releases only and do not accept direct pull requests. All contributions must be submitted to the appropriate dev branch for the corresponding library version.
Getting Started
Before using the plugins from this repository, please ensure that you have completed the OpenHarmony environment setup for the Flutter SDK.
-
Environment Setup
Refer to the documentation in the flutter_flutter repository under the section “Environment Configuration”.
-
Example Reference
Visit the flutter_samples repository to find integration demo examples.
Dependency Reference
Third-party libraries adapted for OpenHarmony should be imported via Git repository. In addition to the required url field, commonly used parameters are as follows:
path: The actual path to the library within the repository; otherwise,pubspec.yamlmay not be found.ref(optional): Specifies the version to fetch, which can be a branch name, tag, or commit ID. If omitted, the repository's default branch will be used.
Reference by Branch:
dev_dependencies:
pigeon:
git:
url: https://gitcode.com/openharmony-tpc/flutter_packages.git
path: packages/pigeon
ref: pigeon-v21.2.0 # Branch name
Reference by Tag:
dev_dependencies:
pigeon:
git:
url: https://gitcode.com/openharmony-tpc/flutter_packages.git
path: packages/pigeon
ref: gitee/pigeon-v11.0.1 # Release tag
Usage Examples
1. Use of tool library pigeon
-
Introduce the pigeon library and add new configuration to dev_dependencies in pubspec.yaml:
dependencies: pigeon: git: url: https://gitcode.com/openharmony-tpc/flutter_packages.git path: packages/pigeon ref: br_pigeon-v26.1.5_ohos -
Run
flutter pub getin the project root directory; -
Run
flutter pub run pigeon in the project root directory --input <dart communication model file path> --arkts_out <arkts platform method code output file path, example./ohos/entry/src/main/ets/xxx.ets>
The template code for communication between Flutter and the OpenHarmony platform will be generated;
- For calling examples, refer to packages/pigeon/example/app/ohos/entry/src/main/ets/plugins/MessagePlugin.ets
2. Use of plug-in library
Take path_provider as an example:
-
In the referenced project, add new dependencies configuration in pubspec.yaml:
dependencies: path_provider: git: url: https://gitcode.com/openharmony-tpc/flutter_packages.git path: packages/path_provider/path_provider ref: br_path_provider-v2.1.5_ohos -
Run
flutter pub getin the project root directory; (ohos/entry/oh-package.json5 will automatically add related plug-in har dependencies) -
Call the path_provider related API in the business code, and it will run normally on the OpenHarmony platform.
Example: Add the path_provider library dependency that supports the OpenHarmony platform to a Flutter-compatible OpenHarmony project;
Reference examples: https://gitcode.com/openharmony-tpc/flutter_samples/tree/master/ohos/pictures_provider_demo.
OpenHarmony Compatible Packages
- Note: A status of
-indicates a pure Dart library that works out of the box.
FAQ
1. Run flutter pub get displayed "File name too long" error
Open the Git Bash or cmd.exe(you need to have git as an environment variable) and execute the following command:
git config --global core.longpaths true
Communication
- Issue Feedback: Submit issues to the Flutter Framework Repository or related third-party libraries.
Introduction
开发者可通过本项目在 Flutter 应用中无缝集成常用插件,最小化业务改动获得完整 OpenHarmony 原生能力支持。项目基于 Flutter 社区官方插件库扩展,新增对 OpenHarmony 平台的兼容适配,提供多个已适配插件及使用示例。【此简介由AI生成】
Customize your domain