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

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
http://www.xdnf.cn/news/9600.html

相关文章:

  • 算力卡上部署OCR文本识别服务与测试
  • w~视觉~合集6
  • 【组件】跳动的图标 动画
  • 实验设计与分析(第6版,Montgomery)第4章随机化区组,拉丁方, 及有关设计4.5节思考题4.1~4.4 R语言解题
  • GRIT:让AI“指着图说话“的新思路
  • get_rga_thread线程和low_camera_venc_thread线程获取低分辨率VENC码流数据
  • ORB-SLAM2学习笔记:ComputeKeyPointsOctTree分析过程记录
  • 【C语言】详解 指针
  • 使用 PySpark 从 Kafka 读取数据流并处理为表
  • 【25软考网工】第九章 网络管理(1)网络管理基础、SNMP
  • 端到端测试最佳实践:从入门到精通的完整指南
  • vue+ts+TinyEditor 是基于 Quill 2.0 开发的富文本编辑器,提供丰富的扩展功能,适用于现代 Web 开发的完整安装使用教程
  • 集成电路制造设备防震基座选型指南:为稳定护航-江苏泊苏系统集成有限公司
  • 手机如何压缩文件为 RAR 格式:详细教程与工具推荐
  • 井喷式增长下的证件缺口:特种设备人才供需矛盾如何破局?
  • 数值积分实验
  • 深入理解计算机科学中的“递归”:原理、应用与优化
  • vue3+Pinia+element-plus 后台管理系统项目实战
  • 安全,稳定可靠的政企即时通讯数字化平台
  • 金山云Q1营收19.7亿元 AI持续释放业务增长新动能
  • 【第2章 绘制】2.13 坐标变换
  • 数据拟合实验
  • IO 中的阻塞、非阻塞、同步、异步及五种IO模型
  • 服务器定时任务查看和编辑
  • SpringBoot Controller接收参数方式
  • Senna代码解读
  • SQLite软件架构与实现源代码浅析
  • 跨平台开发框架electron
  • 【Linux学习笔记】深入理解动静态库本质及其制作
  • 嵌入式学习笔记 - 用typedef定义函数指针