どうも、ちょげ(@chogetarou)です。
DropdownButtonFormFieldに影をつける方法を紹介します。
方法

DropdownButtonFormFieldに影をつけるには、Containerを使います。
まず、DropdownButtonFormFieldをContainerでラップします。
次に、Containerの引数「decoration」にBoxDecorationを指定します。
そして、BoxDecorationの引数「shadow」に影の指定をします。
Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(・・・),
],
),
child: DropdownButton(
value: _text,
items: [
・・・
],
onChanged: (String? value) {
・・・
},
),
),
Containerを使えば、DropdownButtonFormFieldに影をつけることが出来ます。
使用例
以下は、使用例です。

class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
var _text = 'Hello';
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(boxShadow: [
BoxShadow(
color: Colors.grey,
offset: Offset(1.0, 1.0),
blurRadius: 0.8,
spreadRadius: 0.8,
),
]),
child: DropdownButtonFormField(
decoration: InputDecoration(
fillColor: Colors.white,
filled: true,
),
value: _text,
items: [
DropdownMenuItem(
child: Text('Hello'),
value: 'Hello',
),
DropdownMenuItem(
child: Text('Hola'),
value: 'Hola',
),
DropdownMenuItem(
child: Text('こんにちは'),
value: 'こんにちは',
),
],
onChanged: (String? value) {
setState(() {
_text = value ?? 'Hello';
});
},
),
),
),
),
);
}
}

[Flutter]DropdownButtonFormFieldの有効時のアイコンの色を設定するには?
DropdownButtonFormFieldが有効な時のアイコンの色を設定する方法を紹介します。

[Flutter]DropdownButtonのアイコンの色を変えるには?
DropdownButtonのアイコンの色を変える方法を紹介します。

[Flutter]DropdownButtonの背景色を変えるには?
DropdownButtonの背景色を変える方法を紹介します。

[Flutter]DropdownButtonFormFieldの装飾を設定するには?
DropdownButtonFormFieldの装飾を設定する方法を紹介します。
コメント