可以Dropdown Button:
return DropdownButton<String>(
items: <String>['Foo', 'Bar'].map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (_) {},
);
Run Code Online (Sandbox Code Playgroud)
在 a 中有类似于装饰用户的东西TextFormField:
TextFormField(
controller: _titleController,
decoration: InputDecoration(labelText: 'Input'),
validator: (String value) {
if (value != null && value.isEmpty) {
return 'Please enter some text';
}
},
style: Theme.of(context).textTheme.title,
),
Run Code Online (Sandbox Code Playgroud)
当在上面的 TextFormField 中写一些东西时,这个词就会Input显示出来。像这样:
dfm*_*ler 24
用 DropdownButtonFormField 替换 DropdownButton:
https://api.flutter.dev/flutter/material/DropdownButtonFormField-class.html
小智 9
将 DropdownButton 更改为 DropdownButtonFormField 并添加此装饰....
decoration: InputDecoration(
filled: true,
fillColor: Hexcolor('#ecedec'),
labelText: 'Occupation',
border: new CustomBorderTextFieldSkin().getSkin(),
),
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8363 次 |
| 最近记录: |