facebook twitter hatena line email

Flutter/UI/DropdownButton

提供: 初心者エンジニアの簡易メモ
2019年11月14日 (木) 12:55時点におけるAdmin (トーク | 投稿記録)による版 (ページの作成:「==DropdownButtonとは== 複数から1つを選択できるコンボボックス ==サンプル== <pre> String dropdownValue = 'Three'; DropdownButton<String>(...」)

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

DropdownButtonとは

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

サンプル

String dropdownValue = 'Three';

DropdownButton<String>(
                value: dropdownValue,
                icon: Icon(Icons.arrow_downward),
                iconSize: 24,
                elevation: 16,
                style: TextStyle(
                    color: Colors.deepPurple
                ),
                underline: Container(
                  height: 2,
                  color: Colors.deepPurpleAccent,
                ),
                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(),
              ),