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

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