美文网首页
flutter 实现下拉框选择

flutter 实现下拉框选择

作者: 不问出路 | 来源:发表于2019-11-19 18:19 被阅读0次

    Scaffold(

          body: Center(

            child: 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', 'Free', 'Four']

                  .map<DropdownMenuItem<String>>((String value) {

                return DropdownMenuItem<String>(

                  value: value,

                  child: Text(value),

                );

              }).toList(),

            ),

          ),

        );

    相关文章

      网友评论

          本文标题:flutter 实现下拉框选择

          本文链接:https://www.haomeiwen.com/subject/wysgictx.html