HarmonyOS 鸿蒙Next Flutter中Platform.isOhos找不到解决方法
HarmonyOS 鸿蒙Next Flutter中Platform.isOhos找不到解决方法
【关键字】 Flutter / Platform.isOhos / platform.dart
【问题描述】 Flutter中Platform.isOhos找不到。
flutter_flutter\bin\cache\pkg\sky_engine\lib\io\platform.dart 中确实没有isOhos的定义。
三方库版本:
[!] Flutter (Channel dev, 3.7.12-ohos, on Microsoft Windows [版本 10.0.22631.3737], locale zh-CN)
Flutter version 3.7.12-ohos on channel dev at D:\flutter_flutter
! Upstream repository https://gitee.com/openharmony-sig/flutter_flutter.git is not a standard remote.
Set environment variable “FLUTTER_GIT_URL” to https://gitee.com/openharmony-sig/flutter_flutter.git to dismiss
this error.
Framework revision 5d5b44473f (3 days ago), 2024-06-24 10:41:06 +0000
Engine revision 1a65d409c7
Dart version 2.19.6
DevTools version 2.20.1
Pub download mirror https://pub.flutter-io.cn
Flutter download mirror https://storage.flutter-io.cn
If those were intentional, you can disregard the above warnings; however it is recommended to use “git” directly
to perform update checks and upgrades.
[✓] HarmonyOS toolchain - develop for HarmonyOS devices
OpenHarmony Sdk at D:\DevEco Studio\sdk, available api versions has [12:HarmonyOS-NEXT-DB1]
Ohpm version 5.0.2
Node version v18.14.1
Hvigorw binary at D:\DevEco Studio\tools\hvigor\bin\hvigorw
【解决方案】 可以引用该库来解决这个问题:https://pub.dev/packages/flutter_platform_utils,如果有Platform.isOhos 的判断,建议换成 PlatformUtils.isOhos。
1 回复
在HarmonyOS(鸿蒙)中使用Flutter开发时,如果遇到Platform.isOhos
找不到的问题,这通常是因为当前的Flutter SDK或HarmonyOS的Flutter插件版本尚未直接支持通过Platform
类直接判断鸿蒙平台。HarmonyOS支持Flutter的扩展主要通过特定的插件和API来实现。
你可以尝试以下几种方法:
- 确认Flutter SDK和所有相关插件都是最新版本,特别是与HarmonyOS相关的插件。
- 查阅HarmonyOS的Flutter开发文档,了解是否有推荐的方式来识别鸿蒙平台。
- 在社区或论坛中搜索是否有其他开发者遇到并解决了相同的问题。
如果问题依旧没法解决请加我微信,我的微信是itying888。