i want to have tooltip on some word in my textfield so i extended my TextEdditingController so he can convert the word underline to an word with a tooltip but now the cursor have positions problems
This is my class TextEdditingController :
class MyTextEditingController extends TextEditingController {
final GlobalKey _key;
MyTextEditingController(this._key);
@override
TextSpan buildTextSpan({
required BuildContext context,
TextStyle? style,
required bool withComposing,
}) {
final text = this.text;
final List<InlineSpan> textSpanChildren = [];
text.splitMapJoin(RegExp('underline'), onMatch: (m) {
final String underlinedText = m.group(0)!;
textSpanChildren.add(WidgetSpan(
child: Tooltip(
preferBelow: false,
message: 'the message',
child: Text(
underlinedText,
style: style?.merge(const TextStyle(
decoration: TextDecoration.underline, color: Colors.blue)),
),
)));
return '';
}, onNonMatch: (text) {
textSpanChildren.add(TextSpan(text: text, style: style));
return '';
});
return TextSpan(style: style, children: textSpanChildren);
}
}