[Flutter]CupertinoButtonのタップ時の透明度を設定するには?

Flutter

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

CupertinoButtonをタップした時の透明度を設定する方法を紹介します。

スポンサーリンク

方法

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

CuopertinoButtonっをタップした時の透明度を設定するには、引数「pressedOpacity」を使います。

具体的には、CupertinoButtonの引数「pressedOpacity」に透明度を「0〜1」で指定します。
(0に近づくほど透明、1に近づくほど不透明になる)

CupertinoButton(
  pressedOpacity: /*0〜1で透明度を指定*/,
  child: Text('Button'),
  onPressed: () {
    print('Tap');
  },
),

引数「pressedOpacity」を使えば、CupertinoButtonのタップ時の透明度を設定することができます。

使用例

以下は、使用例です。

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        body: Center(
          child: CupertinoButton(
            pressedOpacity: 0.1,
            child: Text('Button'),
            onPressed: () {
              print('Tap');
            },
            color: Colors.blue,
          ),
        ),
      ),
    );
  }

コメント

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