【Flutter】RichTextでテキストの途中で色やサイズを変更する

#Flutter#プログラミング入門#dart#Flutter入門
文字を表示するのはTextウィジェットですが、RichTextを使うことでテキストの途中でスタイルを変えることができます。

RichText(
text: TextSpan(
style: Theme.of(context).textTheme.bodyText2,
children: const [
TextSpan(
text: 'Flutter',
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold, color: Colors.blue)
),
TextSpan(
text: 'ラボ',
style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold, color: Colors.blue)
),
TextSpan(
text: 'は あらゆる角度から',
style: TextStyle(fontSize: 18)
),
TextSpan(
text: 'Flutter',
style: TextStyle(fontSize: 25, fontWeight: FontWeight.bold, color: Colors.blue)
),
TextSpan(
text: 'が学べるサービスです',
style: TextStyle(fontSize: 18)
),
]
),
)
FlutterラボのWEBサイトでも多用しています。