[Flutter]OutlinedButtonを無効にするには?

Flutter

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

OutlinedButtonを押せない状態にする方法を紹介します。

スポンサーリンク

方法

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

OutlinedButtonを無効にするには、引数「onPressed」を使います。

具体的には、OutlinedButtonの引数「onPressed」に「null」を指定します。

OutlinedButton(
  onPressed: null,
  child: Text('Button'),
),

OutlinedButtonの引数「onPressed」にnullを指定することで、OutlinedButtonを無効にすることが出来ます。

使用例

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        body: Center(
          child: OutlinedButton(
            onPressed: null,
            child: Text('Button'),
          ),
        ),
      ),
    );
  }

コメント

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