鸿蒙版Flutter插件库使用 原创

鸿蒙坚果
发布于 2025-3-9 11:27
浏览
0收藏

一、鸿蒙版Flutter插件库使用

以path_provider举例:

在引用的项目中,pubspec.yaml中dependencies新增配置:

dependencies:
  path_provider:
    git:
      url: "https://gitcode.com/openharmony-sig/flutter_packages.git"
      path: "packages/path_provider/path_provider"
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

以shared_preferences举例:

在引用的项目中,pubspec.yaml中dependencies新增配置:

dependency_overrides:
 shared_preferences:
    git:
      url: "https://gitcode.com/openharmony-sig/flutter_packages.git"
      path: "packages/shared_preferences/shared_preferences"
 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.

以url_launcher举例:

在引用的项目中,pubspec.yaml中dependencies新增配置:

dependency_overrides:

 url_launcher:
    git:
      url: "https://gitcode.com/openharmony-sig/flutter_packages.git"
      path: "packages/url_launcher/url_launcher"

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

以flutter_phone_direct_caller举例:

在引用的项目中,pubspec.yaml中dependencies新增配置:

dependency_overrides:
 flutter_phone_direct_caller:
    git:
      url: "https://gitcode.com/openharmony-sig/fluttertpc_flutter_phone_direct_caller.git"

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

大致就是这样,如何想要查看那个库是否适配,

可以查看这儿:

https://gitcode.com/openharmony-sig/flutter_packages

如何判断一个库是纯dart库,还是?

Flutter/Dart生态中,库可以分为纯Dart库和平台相关库。判断一个库是否为纯Dart库的方法有:

  1. 查看pubspec.yaml文件,纯Dart库通常不会有platform-specific的依赖,如android、ios、windows等特定平台的配置
  2. 检查库的目录结构,纯Dart库通常只有lib目录下的dart文件,不会包含android、ios、macos等平台特定的文件夹
  3. 查看pub.dev上该库的说明,纯Dart库通常会标注为"Dart"或"Flutter-compatible"
  4. 纯Dart库不会依赖FFI或平台通道(Platform Channels)与原生代码交互
  5. 如果库的实现需要访问平台特定功能(如相机、文件系统、蓝牙等),那它很可能不是纯Dart库

欢迎大家持续关注坚果派。

©著作权归作者所有,如需转载,请注明出处,否则将追究法律责任
标签
收藏
回复
举报


回复
    相关推荐