Use a type parameter for Dropdown value

This commit is contained in:
Hans Muller
2015-10-22 14:14:11 -07:00
parent bd9036cdb8
commit d25039df30
2 changed files with 11 additions and 10 deletions

View File

@@ -11,17 +11,17 @@ class DropdownDemo extends StatefulComponent {
}
class DropdownDemoState extends State<DropdownDemo> {
dynamic _value = 0;
String _value = "Free";
List <DropdownMenuItem> _buildItems() {
return ["One", "Two", "Free", "Four"].map((String label) {
return new DropdownMenuItem(value: label, child: new Text(label));
return ["One", "Two", "Free", "Four"].map((String value) {
return new DropdownMenuItem<String>(value: value, child: new Text(value));
})
.toList();
}
Widget build(BuildContext context) {
Widget dropdown = new DropdownButton(
Widget dropdown = new DropdownButton<String>(
items: _buildItems(),
value: _value,
onChanged: (dynamic newValue) {