简体   繁体   中英

How to change text color of a tag in TextField Flutter

I'm working on a social media app in Flutter. I'm implementing the comments functionality. When I write a word in comments textfield with "@", it searches the users from firebase cloud firestore. Now, what I want is that when I click on the user tile, the username will append to the textfield in a bold font while other text remain normal. I there a way to achieve this in TextFormField or TextField?

在此处输入图像描述

You can try adding HTML to it

something like this

String complete = "Hello this is @" +"<b>" + someName+ "</b> "; 

you need to add this in onChange listener and detect '@'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM