Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fomat partial text of Text widget in flutter

Tags:

flutter

My Text widget looks like Text("Last Active: some location area..").

I can change text style of complete text using style. but I just like to change Last active as a bold. Text("<b>Last Active</b> some location area name..")

If I go with Row for separate text it will work but render a problem of spacing.

What's the best solution for this. And to make it bold is the only requirement.

Thanks

like image 660
prashant.fepale Avatar asked Oct 16 '18 10:10

prashant.fepale


1 Answers

RichText is solution

RichText(text: TextSpan(children: [
      TextSpan(text: 'Last Active', style: TextStyle(fontWeight: FontWeight.bold)),
      TextSpan(text: ' some location area name..')
    ]))
like image 188
Andrey Turkovsky Avatar answered Sep 22 '22 19:09

Andrey Turkovsky