5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【flutter】テキストのスタイルを設定するには?

Last updated at Posted at 2023-08-28

こんにちは。
今回は、テキストのスタイルを設定する方法を紹介します。

方法

スクリーンショット 2023-08-13 20.18.51.png

Textのテキストを設定するには、引数「style」を使います。

まず、Textの引数「style」にTextStyleを指定します。

そして、
太字にするには、TextStyleの引数「fontWeight」に「FontWeight.bold」を指定します。
文字色を変えるには、TextStyleの引数「color」に「Colors.文字色」を指定します。

使用例

 @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.pink, //背景の色を選択
          title: const Text("Flutter!!!!"), //タイトルを表示
        ),
        body: const Column(
          children: [
            Text(
              "太文字",
              style: TextStyle(fontWeight: FontWeight.bold),//太文字
            ), 
            Text(
              "文字色ピンク",
              style: TextStyle(color: Colors.pink),//文字色ピンク
            ), 
          ],
        ));
  }
}

実行例

スクリーンショット 2023-08-22 17.46.39.png

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?