facebook twitter hatena line email

Flutter/UI/DropdownButton

提供: 初心者エンジニアの簡易メモ
2019年12月6日 (金) 00:13時点におけるAdmin (トーク | 投稿記録)による版

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索

DropdownButtonとは

複数から1つを選択できるコンボボックス

サンプル

String dropdownValue = 'Three';

DropdownButton<String>(
                value: dropdownValue,
                icon: Icon(Icons.arrow_downward),
                iconSize: 24,
                elevation: 16,
                underline: Container(
                  height: 1,
                  color: Colors.grey[600],
                ),
                onChanged: (String newValue) {
                  setState(() {
                    dropdownValue = newValue;
                  });
                },
                items: <String>['One', 'Two', 'Three', 'Four'
                ]
                    .map<DropdownMenuItem<String>>((String value) {
                  return DropdownMenuItem<String>(
                    value: value,
                    child: Text(value),
                  );
                })
                    .toList(),
              ),