[SOLVED] Is there a way of making the first part of formatted string bold?

Issue

This Content is from Stack Overflow. Question asked by JoshuaaMarkk

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);
                  }



Solution

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


This Question was asked in StackOverflow by JoshuaaMarkk and Answered by HTMHell It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?