当前位置: 首页 > news >正文

Flutter3.22适配运行鸿蒙系统问题记录

Flutter3.22适配运行鸿蒙系统问题记录

  • 一:适配条件
  • 适配过程问题记录
    • (1)环境配置问题
    • (2)Concurrent modification during iteration: Instance(length:2) of'_GrowableList 报错
    • (3)三方插件寻找替换

一:适配条件

开源社区在在4月上旬发布了flutter 3.22版本的鸿蒙分支,之前的分支过于老旧,因此可以尝试把自己的项目适配运行

鸿蒙flutter分支地址:

https://gitcode.com/openharmony-sig/flutter_flutter/tree/3.22.0-ohos

已适配三方库地址:

https://gitcode.com/openharmony-sig/flutter_packages#openharmony%E5%B9%B3%E5%8F%B0%E5%B7%B2%E5%85%BC%E5%AE%B9%E5%BA%93

适配过程问题记录

(1)环境配置问题

按照文档配置环境后运行flutter doctor报ohsm sdk找不到,如果按报错去配置环境安装鸿蒙包管理器会很麻烦

直接运行

flutter config --ohos-sdk /Users/vence/Library/OpenHarmony/Sdk(这个地址是自己鸿蒙SDK的安装地址)

如果没有下载sdk在DecEco中自己配置一下
在这里插入图片描述

(2)Concurrent modification during iteration: Instance(length:2) of’_GrowableList 报错

在这里插入图片描述

此问题查阅资料后为flutter3.22分支上的问题,存在编译问题
解决方案:https://github.com/flutter/flutter/issues/148611

在这里插入图片描述

项目全局注释掉MaterialState相关的代码后编译通过。

(3)三方插件寻找替换

已适配三方库地址:

https://gitcode.com/openharmony-sig/flutter_packages#openharmony%E5%B9%B3%E5%8F%B0%E5%B7%B2%E5%85%BC%E5%AE%B9%E5%BA%93

把自己的使用到的三方库查找一遍,如果是纯dart库则不需要替换。涉及到与原生交互的三方库需要替换

以下是自己项目的三方库配置供大家参考

dependencies:flutter:sdk: flutterflutter_localizations:sdk: flutter# getget:git:url: "https://gitcode.com/openharmony-sig/fluttertpc_get.git"# 权限关系permission_handler:git:url: "https://gitcode.com/openharmony-sig/flutter_permission_handler.git"path: "permission_handler"# 二维码扫描mobile_scanner:git:url: "https://gitcode.com/openharmony-sig/fluttertpc_mobile_scanner.git"# # 二维码识别recognition_qrcode:git:url: "https://gitcode.com/openharmony-sig/fluttertpc_recognition_qrcode.git"# 逆定理编码geolocator:git:url: "https://gitcode.com/openharmony-sig/fluttertpc_geolocator.git"path: "geolocator"# 地理编码geocoding:git:url: "https://gitcode.com/openharmony-sig/fluttertpc_geocoding.git"path: "geocoding"# 键盘状态管理flutter_keyboard_visibility:git:url: "https://gitcode.com/openharmony-sig/flutter_keyboard_visibility.git"path: "flutter_keyboard_visibility"# 键盘状态管理keyboard_actions:git:url: "https://gitcode.com/openharmony-sig/fluttertpc_keyboard_actions.git"# 分享share_extend:git:url: "https://gitcode.com/openharmony-sig/fluttertpc_share_extend.git"# toastfluttertoast:git:url: "https://gitcode.com/openharmony-sig/flutter_fluttertoast.git"# 应用安装管理install_plugin:git:url: "https://gitcode.com/openharmony-sig/fluttertpc_install_plugin.git"# webviewflutter_inappwebview:git:url: "https://gitcode.com/openharmony-sig/flutter_inappwebview.git"path: "flutter_inappwebview"# sp存储shared_preferences:git:url: "https://gitcode.com/openharmony-sig/flutter_packages.git"path: "packages/shared_preferences/shared_preferences"# webviewwebview_flutter:git:url: "https://gitcode.com/openharmony-sig/flutter_packages.git"path: "packages/webview_flutter/webview_flutter"# 图片选择image_picker:git:url: "https://gitcode.com/openharmony-sig/flutter_packages.git"path: "packages/image_picker/image_picker"# url管理url_launcher:git:url: "https://gitcode.com/openharmony-sig/flutter_packages.git"path: "packages/url_launcher/url_launcher"# 设备信息获取device_info_plus:git:url: "https://gitcode.com/openharmony-sig/flutter_plus_plugins.git"path: "packages/device_info_plus/device_info_plus"# 文件路径管理path_provider:git:url: "https://gitee.com/openharmony-sig/flutter_packages.git"path: "packages/path_provider/path_provider"# flutter 无需适配的库# 日期格式intl: ^0.19.0# 网络请求dio: ^5.7.0cookie_jar: ^4.0.8dio_cookie_manager: ^3.1.1# 网络图片缓存cached_network_image: ^3.3.1photo_view: ^0.15.0flutter_cache_manager: ^3.1.0# 瀑布流flutter_staggered_grid_view: ^0.7.0# 日志输出插件logger: ^2.0.2+1# 骨架屏skeletonizer: ^1.1.0# 通知event_bus: ^2.0.0# 验证码输入框pin_code_fields: ^8.0.1# 文字轮播marquee: ^2.2.3# SVGflutter_svg: ^2.0.9#banner图card_swiper: ^3.0.0#侧滑删除flutter_slidable: ^3.0.0#动画效果lottie: ^3.1.0#可定位的listviewscrollable_positioned_list: ^0.3.8#rsa加密encrypt: ^5.0.3#虚线边框dotted_border: ^2.1.0# ios 图标库cupertino_icons: ^1.0.2# loaingflutter_easyloading: ^3.0.0# 上拉刷新/下拉加载pull_to_refresh_plus: ^2.0.3# 页面适配flutter_screenutil: ^5.9.0# 图片压缩 2.4版本已经支持鸿蒙flutter_image_compress: ^2.4.0# 这里是为了解决  path_provider 与 cached_network_image 库依赖冲突问题 https://leetcode.cn/discuss/post/3264240/hong-meng-fluttersheng-cheng-hapbao-bian-7utn/
dependency_overrides:path_provider:git:url: https://gitee.com/openharmony-sig/flutter_packages.gitpath: packages/path_provider/path_providerpath_provider_ohos:git:url: https://gitee.com/openharmony-sig/flutter_packages.gitpath: packages/path_provider/path_provider_ohos

相关文章:

  • 数据结构- 10种常见树:二叉树、平衡二叉树、完全二叉树
  • 《全面解析鸿蒙相关概念:鸿蒙、开源鸿蒙、鸿蒙 Next 有何区别》
  • Java SE Cloneable接口和深/浅拷贝
  • 聊一聊 C# NativeAOT 多平台下的函数导出
  • day10机器学习的全流程
  • Python入门手册:模块和包的导入与使用
  • 基于SpringBoot开发一个MCP Server
  • 社区造数服务接入MCP|得物技术
  • JavaScript 中 this 指向全解析:从基础到 Vue 应用
  • C语言 文件操作(2)
  • Nodejs+http-server 使用 http-server 快速搭建本地图片访问服务
  • 不同坐标系下的 面积微元
  • 越南跨境电商免税政策遇冷?工商会为何踩下“刹车”
  • 8086 处理器寄存器超详细解析:从原理到实战
  • BEV和OCC学习-1:数据集以及评估指标
  • 麒麟v10,arm64架构,编译安装Qt5.12.8
  • Python爬虫实战:研究Tornado框架相关技术
  • UDP组播套接字与URI/URL/URN技术详解
  • Qt/C++开发监控GB28181系统/sip协议/同时支持udp和tcp模式/底层协议解析
  • 一文了解智慧教育顶刊《Journal of Computer Assisted Learning》2025年4月研究热点
  • 南京哪家公司做网站/免费学生网页制作成品代码
  • 克隆网站怎么做/网站优化是什么
  • 慈溪 网站建设/免费淘宝关键词工具
  • 有什么网站可以接手工加工做/微信管理系统软件
  • 建设企业展示网站/沈阳关键词快照优化
  • 网站换空间上怎么办/移动网站推广如何优化