[Flutter]MaterialButtonの無効時の色を設定する方法

Flutter

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

MateriaButtonが無効の時の色を設定する方法を紹介します。

スポンサーリンク

方法

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

背景

MaterialButtonが無効の時の背景色を設定するには、引数「disabledColor」を使います。

「disabledColor」に、背景にしたい色を指定します。

MaterialButton(
  disabledColor: Colors.blueGrey,
  child: Text('Button'),
  onPressed: null,
),

テキスト

MaterialButtonが無効の時のテキストの色を設定するには、引数「disabledTextColor」を使います。

「disabledTextColor」に、テキストカラーにしたい色を指定します。

MaterialButton(
  disabledTextColor: Colors.white,
  disabledColor: Colors.blueGrey,
  child: Text('Button'),
  onPressed: null,
)

まとめ

MaterialButtonが無効の時の色は、引数を使って設定します。

背景の色は「disabledColor」、テキストの色は「disabledTextColor」を使います。

コメント

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