首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >光标正在通过表情符号

光标正在通过表情符号
EN

Stack Overflow用户
提问于 2019-07-20 05:28:01
回答 1查看 298关注 0票数 2

当我在maxLines中将TextField设置为null时,对于第一行下面的表情符号,如果您点击表情符号的中心,光标就会穿过中心。

当我添加新的表情符号时,会发生以下情况:

带有游标的表情符号会被破解成无效字符。

以下是TextField的代码:

代码语言:javascript
运行
复制
TextEditingController _commentTextController = TextEditingController();


TextField(
  textInputAction: TextInputAction.send,
  keyboardType: TextInputType.multiline,
  cursorWidth: 1,
  autocorrect: false,
  cursorColor: Colors.black,
  controller: _commentTextController,
  maxLines: null,
  autofocus: true,
  decoration: InputDecoration(
    hintText: "Your comment...",
    enabledBorder: InputBorder.none,
    focusedBorder: InputBorder.none,
  ),
  style: TextStyle(fontSize: 15),
)

当我试图用以下代码在TextField中提取和设置新文本时:

代码语言:javascript
运行
复制
String currentComment = _commentTextController.text;

String newCommentText = currentComment + ""

setState(() {
  _commentTextController = TextEditingController(text: newCommentText);
});

TextField随下列日志消失:

代码语言:javascript
运行
复制
I/flutter (27958): Another exception was thrown: Invalid argument(s): string is not well-formed UTF-16
I/flutter (27958): Another exception was thrown: NoSuchMethodError: The getter 'alphabeticBaseline' was called on null.
I/flutter (27958): Another exception was thrown: NoSuchMethodError: The method 'getBoxesForRange' was called on null.
I/flutter (27958): Another exception was thrown: Please see the documentation for computeDistanceToActualBaseline for the required calling conventions of this method.

我在下面添加了gif,以显示第一行以下行的表情符号行为有多糟糕。

简而言之,只需将maxLines设置为TextField或TextFormField中的null即可。

编辑: CupertinoTextField没有这个bug,所以我想我会试一试,直到这是固定的

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-24 10:38:12

这个问题是由颤振小组解决的。https://github.com/flutter/engine/pull/10063

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57122054

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档