[flutter] RichText에서 텍스트 강조 표시하기

우선, RichText 위젯을 만들고 TextSpan을 사용하여 각 텍스트 스타일을 정의합니다. 다음은 글자 중 일부를 강조하여 표시하는 간단한 예제입니다.

RichText(
  text: TextSpan(
    text: 'Hello',
    style: TextStyle(color: Colors.black),
    children: <TextSpan>[
      TextSpan(
        text: ' flutter',
        style: TextStyle(fontWeight: FontWeight.bold, color: Colors.blue),
      ),
    ],
  ),
)

위의 예제에서 “flutter”라는 단어가 강조되어 표시됩니다. 이와 같이 RichTextTextSpan을 조합하여 원하는 형태로 텍스트를 강조 표시할 수 있습니다.

참고 문헌: