I want to implement in Flutter a popup dictionary. More precisely, I have a RichText widget and I want, when the user tap it, to get the text index, the TextPosition, corresponding to where the user have tapped to be able to get the surrounding text and process it and then display a popup displaying the definitions of the word found.
But I don't know how to get the TextPosition from a tap position.
From the comment on this question, I understand that first I need to have a GestureDetector to define a tap callback. Then from the event argument compute the offset into the coordinates of the corresponding RenderParagraph and call RenderParagraph.getPositionForOffset() to get the text position.
But I am a beginner at Flutter and I don't know how I can access the corresponding RenderParagraph or whatever object having the wanted information from the tap callack. I got all my dictionary popup system working except for this word detection part.
Can anyone help me with this part ?
Please use Below code for get text position