[Flutter]Text(テキスト)に枠線をつけるには?

Flutter

どうも、ちょげ(@chogetarou)です。

Textに枠線をつける方法を紹介します。

スポンサーリンク

方法

インターフェース, インターネット, プログラム, ブラウザ, Www

Textに枠線をつけるには、Containerを使います。

まず、ContainerでTextをラップします。

次に、Containerの引数「decoration」にBoxDecorationを指定します。

そして、BoxDecorationの引数「border」に「Boder.all()」を指定します。

Container(
  decoration: BoxDecoration(
    border: Border.all(),
  ),
  child: Text('テキスト'),
),

Containerを使えば、Textに枠線をつけることが出来ます。

使用例

以下は、使用例です。

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Container(
          decoration: BoxDecoration(
            border: Border.all(),
          ),
          child: Text('Hello Flutter'),
          padding: EdgeInsets.all(8.0),
        ),
      ),
    );
  }

コメント

タイトルとURLをコピーしました