HarmonyOS 鸿蒙Next flutter 3.7.12 输入框 粘贴的时候报错

发布于 1周前 作者 sinazl 来自 鸿蒙OS

HarmonyOS 鸿蒙Next flutter 3.7.12 输入框 粘贴的时候报错

➜ ~ flutter doctor -v
• Flutter version 3.7.12-ohos on channel dev at /Users/wangxiaojian18/DevecostudioProjects/flutter_flutter
• Upstream repository https://gitee.com/openharmony-sig/flutter_flutter.git
• FLUTTER_GIT_URL = https://gitee.com/openharmony-sig/flutter_flutter.git
• Framework revision 0e1a3ca6e5 (4 weeks ago), 2024-10-15 15:12:24 +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

• HarmonyOS toolchain - develop for HarmonyOS devices
• OpenHarmony Sdk at /Applications/DevEco-Studio.app/Contents/sdk, available api versions has [12:default]
• Ohpm version 5.0.8
• Node version v16.20.2
• Hvigorw binary at /Applications/DevEco-Studio.app/Contents/tools/hvigor/bin/hvigorw

• Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/wangxiaojian18/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/wangxiaojian18/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
• All Android licenses accepted.

• Xcode - develop for iOS and macOS (Xcode 15.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15C500b
• CocoaPods version 1.15.2

• Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

• Android Studio (version 2023.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
• Dart plugin can be installed from:

• IntelliJ IDEA Ultimate Edition (version 2024.2.1)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 81.1.3
• Dart plugin version 242.21829.3

• VS Code (version 1.94.2)
• VS Code at /Users/wangxiaojian18/workspace/software/Visual Studio Code.app/Contents
• Flutter extension can be installed from:

• Connected device (4 available)
• ELE AL00 (mobile) • 8KE0220320003725 • android-arm64 • Android 10 (API 29)
• 23E0224126001000 (mobile) • 23E0224126001000 • ohos-arm64 • Ohos OpenHarmony-5.0.1.73 (API 13)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.1 23B2073 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 130.0.6723.117

• HTTP Host Availability
• All required HTTP hosts are available

flutter 输入框粘贴剪切板的内容报错:

11-11 18:11:11.738 55573 55611 W A00000/com.jd.jdd/XComFlutterOHOS_Native: flutter settings log message: ----------->>Exception caught: PlatformException(error, Failed to request permissions from user.Cause: Invalid request, null, null) -> #0 JSONMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:171:7)
11-11 18:11:11.738 55573 55611 W A00000/com.jd.jdd/XComFlutterOHOS_Native: flutter settings log message: #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:315:18)
11-11 18:11:11.738 55573 55611 W A00000/com.jd.jdd/XComFlutterOHOS_Native: flutter settings log message: <asynchronous suspension>
11-11 18:11:11.738 55573 55611 W A00000/com.jd.jdd/XComFlutterOHOS_Native: flutter settings log message: #2 Clipboard.getData (package:flutter/src/services/clipboard.dart:54:42)
11-11 18:11:11.738 55573 55611 W A00000/com.jd.jdd/XComFlutterOHOS_Native: flutter settings log message: <asynchronous suspension>
11-11 18:11:11.738 55573 55611 W A00000/com.jd.jdd/XComFlutterOHOS_Native: flutter settings log message: #3 EditableTextState.pasteText (package:flutter/src/widgets/editable_text.dart:2129:33)
11-11 18:11:11.738 55573 55611 W A00000/com.jd.jdd/XComFlutterOHOS_Native: flutter settings log message: <asynchronous suspension>

更多关于HarmonyOS 鸿蒙Next flutter 3.7.12 输入框 粘贴的时候报错的实战系列教程也可以访问 https://www.itying.com/category-92-b0.html

2 回复

是否使用了TextField组件进行粘贴,是的话,接口变更,编辑框粘贴需要弹窗授权申请ohos.permission.READ_PASTEBOARD权限

链接:https://developer.huawei.com/consumer/cn/doc/app/agc-help-add-releaseprofile-0000001914714796

https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/declare-permissions-in-acl-V5

更多关于HarmonyOS 鸿蒙Next flutter 3.7.12 输入框 粘贴的时候报错的实战系列教程也可以访问 https://www.itying.com/category-92-b0.html


针对HarmonyOS鸿蒙Next环境中,使用Flutter 3.7.12版本时输入框粘贴功能报错的问题,可能的原因及解决方案如下:

  1. 权限问题: 确认应用是否已请求并获得了必要的剪贴板访问权限。在鸿蒙系统中,权限管理较为严格,未授权可能导致粘贴功能异常。

  2. Flutter框架兼容性问题: Flutter 3.7.12版本可能在鸿蒙Next系统上存在某些未修复的bug,特别是与文本输入和剪贴板操作相关的功能。检查Flutter社区或鸿蒙开发者论坛是否有相关问题的报告和解决方案。

  3. 系统API调用异常: 鸿蒙系统的API可能与Android或iOS有所不同,如果Flutter框架中的某些调用未适配鸿蒙系统,可能导致粘贴功能出错。考虑是否有必要调整代码,使用鸿蒙系统特定的API或方法。

  4. 第三方库冲突: 如果项目中使用了第三方库来处理文本输入或剪贴板操作,检查这些库是否与Flutter 3.7.12版本或鸿蒙系统兼容。

如果上述方法无法解决问题,可能是由于更复杂的系统或框架层面的bug导致。此时,建议直接联系鸿蒙系统的开发者支持或访问鸿蒙开发者论坛寻求帮助。如果问题依旧没法解决请联系官网客服,官网地址是 https://www.itying.com/category-93-b0.html

回到顶部