RichText 위젯은 여러 개의 TextSpan 위젯을 포함할 수 있으므로 각각 다른 스타일과 텍스트를 가질 수 있습니다.
RichText(
text: TextSpan(
text: 'Hello ',
style: TextStyle(color: Colors.black),
children: [
WidgetSpan(
child: Icon(
Icons.call,
color: Colors.white,
size: 18,
),
),
TextSpan(
text: 'World',
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
),
),
],
),
)
Text.rich()는 RichText 위젯과 비슷하지만 더 간단하게 작성할 수 있습니다.
Text.rich(
TextSpan(
text: 'Hello ',
style: TextStyle(color: Colors.black),
children: [
WidgetSpan(
child: Icon(
Icons.call,
color: Colors.white,
size: 18,
),
),
TextSpan(
text: 'World',
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
),
),
],
),
)