どうも、ちょげ(@chogetarou)です。
ElevatedButtonの影の大きさを設定する方法を紹介します。
方法

ElevatedButtonの影の大きさを設定するには、引数「style」を使います。
まず、ElevatedButtonの引数「style」にElevatedButton.styleFromを指定します。
そして、styleFromの引数「elevation」に影の大きさを指定します。
ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: shadowSize, //影の大きさ
),
・・・
),
ElevatedButton.styleFromの引数「elevation」に指定した数値が、ElevatedButtonの影の大きさに設定されます。
使用例

@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Center(
child: ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 20,
),
onPressed: () {
print("Button Tap");
},
child: Text('Button'),
),
),
),
);
}
コメント