どうも、ちょげ(@chogetarou)です。
ElevatedButtonのスプラッシュカラーを変える方法を紹介します。
方法

ElevatedButtonのスプラッシュカラーを変えるには、引数「style」を使います。
まず、ElevatedButtonの引数「style」にElevatedButton.styleFromを指定します。
そして、ElevatedButton.styleFromの引数「onPrimary」にスプラッシュカラーを指定します。
ElevatedButton(
style: ElevatedButton.styleFrom(
onPrimary: splashColor, //スプラッシュカラー
),
・・・
),
ElevatedButton.styleFromの引数「onPrimary」に設定した色がスプラッシュカラーになります。
使用例
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Center(
child: ElevatedButton(
style: ElevatedButton.styleFrom(
onPrimary: Colors.pink,
),
onPressed: () {},
child: Text(
'Button',
style: TextStyle(color: Colors.white),
),
),
),
),
);
}
コメント