[Flutter]OutlinedButtonの高さを設定するには?

Flutter

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

OutlinedButtonの高さを設定する方法を紹介します。

スポンサーリンク

方法

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

OutlinedButtonの高さを設定するには、引数「style」を使います。

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

そして、styleFromの引数「fixedSize」に高さを指定します。

高さの指定は、Sizeクラスでします。

OutlinedButton(
  style: OutlinedButton.styleFrom(
    fixedSize: Size.fromHeight(高さ), //Sizeクラスで高さを指定
  ),
  onPressed: () {},
  child: Text('Button'),
),

OutlinedButton.styleFromの引数「fixedSize」に指定した高さが、OutlinedButtonの高さに設定されます。

使用例

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        body: Center(
          child: OutlinedButton(
            style: OutlinedButton.styleFrom(
              fixedSize: Size.fromHeight(100.0),
            ),
            onPressed: () {},
            child: Text('Button'),
          ),
        ),
      ),
    );
  }

コメント

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