[Flutter]ButtonStyleの引数「shape」を使う方法

Flutter

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

ButtonStyleの引数「shape」を使う方法を紹介します。

スポンサーリンク

方法

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

ButtonStyleの引数「shape」を使うには、MaterialStatePropertyクラスを指定します。

具体的には、「MaterialStateProperty.all<クラス>(クラス)」のように指定します。

MaterialStatePropertyStateクラスに指定するクラスは、実際の形を指定するためのものです。

例えば、角丸の四角形の形を指定するRoundedRectangleBorderクラスの場合は、次のようになります。

MaterialStateProperty.all<RoundedRectangleBorder>(
     RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(20),
    ),
 ),

まとめ

ButtonStyleの引数「shape」を使うには、MaterialStatePropertyクラスを使って形を指定します。

コメント

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