[Flutter]TextButtonのパディングを設定する方法

Flutter

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

TextButtonのパディングを設定する方法を紹介します。

スポンサーリンク

方法

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

TextButtonのパディングを設定するには、「TextButton.styleFrom」を使います。

まず、TextButtonの引数「style」に「TextButton.styleFrom」を指定します。

そして、TextButton.styleFromの引数「padding」でパディングを設定します。

           TextButton(
              onPressed: () {},
              child: Text('Button'),
              style: TextButton.styleFrom(
                backgroundColor: Colors.yellow,
                padding: EdgeInsets.all(20), //パディング
              ),
            )

TextButton.styleFromの引数「padding」に指定する「EgeInsets.all()」に、パディングの数値を設定します。

まとめ

TextButtonのパディングを設定するには、引数「style」に「TextButton.styleFrom」を指定します。

そして、TextButton.styleFromの引数「padding」でパディングを設定します。

コメント

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