lx_flutter_packages_fix:基于 OpenHarmony 生态的 Flutter 库兼容适配项目

可用于在 OpenHarmony 平台上使用多种常用 Flutter 库。项目新增对 OpenHarmony 平台的兼容,已适配 pigeon、image_picker、shared_preferences 等多个主流 Flutter 库,提供不同版本推荐。【此简介由AI生成】

Branch89Tags42

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:

  1. Identify the Target Branch: Locate the appropriate dev branch for the third-party library and version you intend to modify.

  2. Develop from the Dev Branch: Fork the repository and create your feature branch from the corresponding dev branch.

  3. 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.yaml may 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

  1. 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
    
  2. Run flutter pub get in the project root directory;

  3. 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;

  1. 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:

  1. 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
    
  2. Run flutter pub get in the project root directory; (ohos/entry/oh-package.json5 will automatically add related plug-in har dependencies)

  3. 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

No Original Package Name Flutter Framework Recommended Version Original Package Version release Branch Dev Branch Tag Status
1 pigeon 3.7 14.0.0 master dev pigeon-v14.0.0-ohos-1.0.0 Adapted
3.22 21.2.0 pigeon-v21.2.0 pigeon-v21.2.0 Adapted
3.27 25.3.2 br_pigeon-v25.3.2_ohos br_pigeon-v25.3.2_ohos_dev pigeon-v25.3.2-ohos-1.0.0 Adapted
3.35 26.1.5 br_pigeon-v26.1.5_ohos br_pigeon-v26.1.5_ohos_dev pigeon-v26.1.5-ohos-1.0.0 Adapted
2 file_selector 3.7 1.0.1 master dev file_selector-v1.0.1-ohos-1.0.0 Adapted
3.22 1.0.3 br_file_selector-v1.0.3_ohos br_file_selector-v1.0.3_ohos_dev file_selector-v1.0.3-ohos-1.0.0 Adapted
3.27 1.0.3 br_file_selector-v1.0.3_ohos br_file_selector-v1.0.3_ohos_dev file_selector-v1.0.3-ohos-1.0.0 Adapted
3.35 1.1.0 br_file_selector-v1.1.0_ohos br_file_selector-v1.1.0_ohos_dev file_selector-v1.1.0-ohos-1.0.0 Adapted
3 image_picker 3.7 1.0.4 master dev image_picker-v1.0.4-ohos-1.0.0 Adapted
3.22 1.1.2 br_image_picker-v1.1.2_ohos br_image_picker-v1.1.2_ohos_dev image_picker-v1.1.2-ohos-1.0.0 Adapted
3.27 1.1.2 br_image_picker-v1.1.2_ohos br_image_picker-v1.1.2_ohos_dev image_picker-v1.1.2-ohos-1.0.0 Adapted
3.35 1.2.1 br_image_picker-v1.2.1_ohos br_image_picker-v1.2.1_ohos_dev image_picker-v1.2.1-ohos-1.0.0 Adapted
4 animations 3.7 master dev -
3.22 master dev -
3.27 2.0.11 br_animations-v2.0.11_ohos - -
3.35 2.0.11 br_animations-v2.0.11_ohos - -
5 url_launcher 3.7 6.1.11 master dev url_launcher_v6.1.11-ohos-1.0.0 Adapted
3.22 6.3.0 br_url_launcher-v6.3.0_ohos br_url_launcher-v6.3.0_ohos_dev url_launcher_v6.3.0-ohos-1.0.0 Adapted
3.27 6.3.1 br_url_launcher_v6.3.1_ohos br_url_launcher_v6.3.1_ohos_dev url_launcher_v6.3.1-ohos-1.0.0 Adapted
3.35 6.3.2 br_url_launcher-v6.3.2_ohos br_url_launcher-v6.3.2_ohos_dev url_launcher_v6.3.2-ohos-1.0.0 Adapted
6 shared_preferences 3.7 2.2.2 master dev shared_preferences-v2.2.2-ohos-1.0.0 Adapted
3.22 2.3.2 br_shared_preferences-v2.3.2_ohos br_shared_preferences-v2.3.2_ohos_dev shared_preferences-v2.3.2-ohos-1.0.0 Adapted
3.27 2.5.3 br_shared_preferences-v2.5.3_ohos br_shared_preferences-v2.5.3_ohos_dev shared_preferences-v2.5.3-ohos-1.0.0 Adapted
3.35 2.5.4 br_shared_preferences-v2.5.4_ohos br_shared_preferences-v2.5.4_ohos_dev shared_preferences-v2.5.4-ohos-1.0.0 Adapted
7 path_provider 3.7 2.1.1 master dev provider-v2.1.1-ohos-1.0.0 Adapted
3.22 2.1.4 br_path_provider-v2.1.4_ohos - provider-v2.1.4_ohos-1.0.0 Adapted
3.27 2.1.5 br_path_provider-v2.1.5_ohos br_path_provider-v2.1.5_ohos_dev provider-v2.1.5-ohos-1.0.0 Adapted
3.35 2.1.5 br_path_provider-v2.1.5_ohos br_path_provider-v2.1.5_ohos_dev provider-v2.1.5-ohos-1.0.0 Adapted
8 local_auth 3.7 2.1.6 master dev local_auth-v2.1.6-ohos-1.0.0 Adapted
3.22 2.3.0 br_local_auth-v2.3.0_ohos br_local_auth-v2.3.0_ohos_dev local_auth-v2.3.0-ohos-1.0.0 Adapted
3.27 2.3.0 br_local_auth-v2.3.0_ohos br_local_auth-v2.3.0_ohos_dev local_auth-v2.3.0-ohos-1.0.0 Adapted
3.35 3.0.0 br_local_auth-v3.0.0_ohos br_local_auth-v3.0.0_ohos_dev local_auth-v3.0.0-ohos-1.0.0 Adapted
9 camera 3.7 0.10.5+5 master dev camera-v0.10.5_5-ohos-1.0.0 Adapted
3.22 0.11.0+2 br_camera-v0.11.0+2_ohos br_camera-v0.11.0_2_ohos_dev camera-v0.11.0_2-ohos-1.0.0 Adapted
3.27 0.11.1 br_camera-v0.11.1_ohos br_camera-v0.11.1_ohos_dev camera-v0.11.1-ohos-1.0.0 Adapted
3.35 0.11.3 br_camera-v0.11.3_ohos br_camera-v0.11.3_ohos_dev camera-v0.11.3-ohos-1.0.0 Adapted
10 video_player 3.7 2.7.2 master dev video_player-v2.7.2-ohos-1.0.0 Adapted
3.22 2.9.2 br_video_player-v2.9.2_ohos br_video_player-v2.9.2_ohos_dev video_player-v2.9.2-ohos-1.0.0 Adapted
3.27 2.10.0 br_video_player-v2.10.0_ohos br_video_player-v2.10.0_ohos_dev video_player-v2.10.0-ohos-1.0.0 Adapted
3.35 2.10.1 br_video_player-v2.10.1_ohos br_video_player-v2.10.1_ohos_dev video_player-v2.10.1-ohos-1.0.0 Adapted
11 webview_flutter 3.7 4.4.2 master dev webview_flutter-v4.4.2-ohos-1.0.0 Adapted
3.22 4.8.0 br_webview_flutter-v4.8.0_ohos br_webview_flutter-v4.8.0_ohos_dev webview_flutter-v4.8.0-ohos-1.0.0 Adapted
3.27 4.13.0 br_webview_flutter-v4.13.0_ohos br_webview_flutter-v4.13.0_ohos_dev webview_flutter-v4.13.0-ohos-1.0.0 Adapted
3.35 4.13.0 br_webview_flutter-v4.13.0_ohos br_webview_flutter-v4.13.0_ohos_dev webview_flutter-v4.13.0-ohos-1.0.0 Adapted
12 webview_flutter-v4.4.4 4.4.4 master dev Adapted
13 in_app_purchase 3.7 3.1.11 master dev in_app_purchase_v3.1.11-ohos-1.0.0 Adapted
3.22 3.2.0 br_in_app_purchase-v3.2.0_ohos br_in_app_purchase-v3.2.0_ohos_dev in_app_purchase_v3.2.0-ohos-1.0.0 Adapted
3.27 3.2.3 br_in_app_purchase-v3.2.3_ohos br_in_app_purchase-v3.2.3_ohos_dev in_app_purchase_v3.2.3-ohos-1.0.0 Adapted
3.35 3.2.3 br_in_app_purchase-v3.2.3_ohos br_in_app_purchase-v3.2.3_ohos_dev in_app_purchase_v3.2.3-ohos-1.0.0 Adapted
14 css_colors - - - -
15 flutter_adaptive_scaffold - - - -
16 flutter_image - - - -
17 flutter_lints - - - -
18 flutter_markdown - - - -
19 flutter_migrate - - - -
20 go_router - - - -
21 go_router_builder - - - -
22 metrics_center - - - -
23 multicast_dns - - - -
24 palette_generator - - - -
25 pointer_interceptor - - - -
26 rfw - - - -
27 standard_message_codec - - - -
28 two_dimensional_scrollables - - - -
29 web_benchmarks - - - -
30 xdg_directories - - - -
  • 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

Introduction

可用于在 OpenHarmony 平台上使用多种常用 Flutter 库。项目新增对 OpenHarmony 平台的兼容,已适配 pigeon、image_picker、shared_preferences 等多个主流 Flutter 库,提供不同版本推荐。【此简介由AI生成】

Customize your domain