Home > Blockchain >  Is there a way of making the first part of formatted string bold?
Is there a way of making the first part of formatted string bold?

Time:09-19

Is there a way of making *{innerItem.key} bold? Thanks

final List<String> values =  [];
                  for(final item in incidentList){
                    String groupedElement = "";
                    for(var innerItem in item.entries)
                    {
                      groupedElement  = "${innerItem.key}  : ${innerItem.value}\n";
                    }
                    values.add(groupedElement);
                  }

CodePudding user response:

You are looking for RichText:

Text.rich(
  TextSpan(
    children: [
      TextSpan(
        text: "${innerItem.key}: ",
        style: TextStyle(fontWeight: FontWeight.bold),
      ),
      TextSpan(text: "${innerItem.value}\n"),
    ],
  ),
)

And of course, it will have to be a list of Widget, and not string

CodePudding user response:

You can use the flutter_html package and the to put a String with HTML format

ex:

Html(
  data: '<body><b>This text is gonna be bold</b><br>This gonna be normal</body>',
  style: {
            'body': Style(
              fontSize: 18,
            ),
            'b': Style(
              fontSize: 18,
              fontWeight: FontWeight.bold,
            ),
);

Also, you can customize the styling of your text using HTML tags(or your custom tags) from styles Map property

  • Related