どうも、ちょげ(@chogetarou)です。
Textの背景色を設定する方法を紹介します。
方法

Textの背景色を設定する方法は、2つあります。
style
1つは、引数「style」を使う方法です。
まず、Textの引数「style」にTextStyleを指定します。
そして、TextStyleの引数「backgroundColor」に背景色を指定します。
Text(
'テキスト',
style: TextStyle(
backgroundColor: /*背景色*/,
),
),
Container
もう1つは、Containerを使う方法です。
まず、TextをContainerでラップします。
そして、Containerの引数「color」に背景色を指定します。
Container(
color: /*背景色*/,
child: Text('テキスト'),
),
まとめ
Textの背景色を設定する方法は、次の2つです。
- 引数「style」を使う方法
- Containerを使う方法
コメント