可用于在 OpenHarmony 平台上使用多种常用 Flutter 库。项目新增对 OpenHarmony 平台的兼容,已适配 pigeon、image_picker、shared_preferences 等多个主流 Flutter 库,提供不同版本推荐。【此简介由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): Specify the version to be pulled, which can be the **branch name **, **tag **, or commit id. If not written, use the default branch of the repository. It is recommended to use the **tag **.
Reference by Tag:
dev_dependencies:
pigeon:
git:
url: https://gitcode.com/openharmony-tpc/flutter_packages.git
path: packages/pigeon
ref: pigeon-v26.1.5-ohos-1.0.0 # Release tag
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
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: pigeon-v26.1.5-ohos-1.0.0 -
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: provider-v2.1.5-ohos-1.0.0 -
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
可用于在 OpenHarmony 平台上使用多种常用 Flutter 库。项目新增对 OpenHarmony 平台的兼容,已适配 pigeon、image_picker、shared_preferences 等多个主流 Flutter 库,提供不同版本推荐。【此简介由AI生成】
Customize your domain