如何在TextFormField(最好使用TextedingController)中获得当前的光标位置?

发布于 2025-02-09 08:21:35 字数 436 浏览 2 评论 0原文

我正在尝试实现类似于Instagram的“注释用户”功能。

要求:

  • 当用户在“@”之后键入一个或多个字符时,应显示用户列表。
  • 要查询的术语可以在文本中的任何地方,而不仅仅是最后。
  • 可以有多个标记的用户。

找到 this flutter中用户tagging的答案,但是仅当标签在文本的末尾时,它才显示一个建议列表。打字。如果我可以根据textformfield中的当前光标位置修改此行为,那将是很棒的。我查看了textedingcontroller api,以找到类似的东西,但找不到任何有用的东西。

有什么方法可以获取此类信息,还是我缺少一些东西?

I am trying to implement the 'Tagging users in comments' feature similar to Instagram.

Requirements:

  • A list of users should be shown when a user types one or more characters after '@'.
  • The term to be queried can be anywhere in the text and not just at the end.
  • There can be more than one tagged user.

Found this answer for user-tagging in Flutter, but it shows a suggestion list only if the tag is at the end of the text while typing. It would be great if I could modify this behavior based on the current cursor position in the TextFormField. I looked at the TextEditingController API to find something similar but could not find anything useful.

Is there any way to get such information or am I missing something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对不⑦ 2025-02-16 08:21:35

根据您的要求:

其他有用的软件包: https://pub.dev/packages? a>

注意:由于您尚未提供任何代码,我无法提供适当的解决方案,但是所有链接都会有助于获取您的解决方案。

As per your requirements:

Other useful packages: https://pub.dev/packages?q=mention

Note: As you haven't provided any code, I can't give a proper solution, but all the links will be helpful to get your solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文