Flutter DropdownButtonのアイコンの有効時の色を設定するサンプル

環境
Windows11 pro 64bit
Flutter 3.3.7

構文

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
DropdownButton(
iconEnabledColor: /*アイコンの有効時の色*/,
value: _text,
DropdownButton( iconEnabledColor: /*アイコンの有効時の色*/, value: _text,
DropdownButton(
  iconEnabledColor: /*アイコンの有効時の色*/,
  value: _text,

DropdownButtonの引数「iconEnabledColor」にアイコンの有効時の色を指定します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
class Sample extends StatefulWidget {
@override
_SampleState createState() => _SampleState();
}
class _SampleState extends State<Sample> {
var _text = 'study';
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: DropdownButton(
iconEnabledColor: Colors.pink,
value: _text,
items: [
DropdownMenuItem(
child: Text('study'),
value: 'study',
),
DropdownMenuItem(
child: Text('12345'),
value: '12345',
),
],
onChanged: (String? value) {
setState(() {
_text = value ?? 'study';
});
},
),
),
);
}
}
class Sample extends StatefulWidget { @override _SampleState createState() => _SampleState(); } class _SampleState extends State<Sample> { var _text = 'study'; @override Widget build(BuildContext context) { return Scaffold( body: Center( child: DropdownButton( iconEnabledColor: Colors.pink, value: _text, items: [ DropdownMenuItem( child: Text('study'), value: 'study', ), DropdownMenuItem( child: Text('12345'), value: '12345', ), ], onChanged: (String? value) { setState(() { _text = value ?? 'study'; }); }, ), ), ); } }
class Sample extends StatefulWidget {
  @override
  _SampleState createState() => _SampleState();
}

class _SampleState extends State<Sample> {
  var _text = 'study';
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: DropdownButton(
          iconEnabledColor: Colors.pink,
          value: _text,
          items: [
            DropdownMenuItem(
              child: Text('study'),
              value: 'study',
            ),
            DropdownMenuItem(
              child: Text('12345'),
              value: '12345',
            ),
          ],
          onChanged: (String? value) {
            setState(() {
              _text = value ?? 'study';
            });
          },
        ),
      ),
    );
  }
}

 

Flutter

Posted by arkgame