How to get current cursor position in TextFormField (preferrably using TextEditingController)?

338 Views Asked by At

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?

1

There are 1 best solutions below

1
Pratik Butani On

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.