flutter 实现下拉框选择

2019-11-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(),

        ),

      ),

    );

上一篇下一篇

猜你喜欢

热点阅读