TextInputAction.next not going to next field when has a suffixIcon in Flutter

huangapple go评论54阅读模式
英文:

TextInputAction.next not going to next field when has a suffixIcon in Flutter

问题

我有一个问题,使用TextFormFieldTextInputAction.next时。

当我使用suffixIcon时,焦点在suffixIcon上而不是在表单中的下一个字段上。

英文:

I have a problem with TextFormField using TextInputAction.next.

When I'm using suffixIcon the focus is on suffixIcon and not on the next field in my form.

答案1

得分: 1

我的解决方案是将一个 Focus 小部件添加到我的 suffixIcon 并将标志 canRequestFocusdescendantsAreFocusable 设置为 false。

示例:

Widget _suffixIcon() {
  return Focus(
    canRequestFocus: false,
    descendantsAreFocusable: false,
    child: Icon(Icons.person), // 任何图标或自定义小部件
  );
}
TextFormField(
  decoration: InputDecoration(suffix: _suffixIcon()),
  //...
)
英文:

My solution was to add a Focus widget to my suffixIcon and set the flags canRequestFocus and descendantsAreFocusable to false.

Example:

Widget _suffixIcon() {
  return Focus(
    canRequestFocus: false,
    descendantsAreFocusable: false,
    child: Icon(Icons.person), //Any icon or a custom widget
  );
}
TextFormField(
  decoration: InputDecoration(suffix: _suffixIcon()),
  //...
)

huangapple
  • 本文由 发表于 2023年5月18日 02:13:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76275072.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定