DropdownButton hint (#7114)
This commit is contained in:
@@ -132,7 +132,8 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
|
||||
// https://en.wikipedia.org/wiki/Free_Four
|
||||
String dropdown1Value = 'Free';
|
||||
String dropdown2Value = 'Four';
|
||||
String dropdown2Value;
|
||||
String dropdown3Value = 'Four';
|
||||
|
||||
Widget buildDropdownButton() {
|
||||
return new Padding(
|
||||
@@ -141,7 +142,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
new ListItem(
|
||||
title: new Text('Scrollable dropdown:'),
|
||||
title: new Text('Simple dropdown:'),
|
||||
trailing: new DropdownButton<String>(
|
||||
value: dropdown1Value,
|
||||
onChanged: (String newValue) {
|
||||
@@ -149,6 +150,47 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
dropdown1Value = newValue;
|
||||
});
|
||||
},
|
||||
items: <String>['One', 'Two', 'Free', 'Four'].map((String value) {
|
||||
return new DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: new Text(value),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
new SizedBox(
|
||||
height: 24.0,
|
||||
),
|
||||
new ListItem(
|
||||
title: new Text('Dropdown with a hint:'),
|
||||
trailing: new DropdownButton<String>(
|
||||
value: dropdown2Value,
|
||||
hint: new Text('Choose'),
|
||||
onChanged: (String newValue) {
|
||||
setState(() {
|
||||
dropdown2Value = newValue;
|
||||
});
|
||||
},
|
||||
items: <String>['One', 'Two', 'Free', 'Four'].map((String value) {
|
||||
return new DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: new Text(value),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
new SizedBox(
|
||||
height: 24.0,
|
||||
),
|
||||
new ListItem(
|
||||
title: new Text('Scrollable dropdown:'),
|
||||
trailing: new DropdownButton<String>(
|
||||
value: dropdown3Value,
|
||||
onChanged: (String newValue) {
|
||||
setState(() {
|
||||
dropdown3Value = newValue;
|
||||
});
|
||||
},
|
||||
items: <String>[
|
||||
'One', 'Two', 'Free', 'Four', 'Can', 'I', 'Have', 'A', 'Little',
|
||||
'Bit', 'More', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten'
|
||||
@@ -162,26 +204,6 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
new SizedBox(
|
||||
height: 24.0,
|
||||
),
|
||||
new ListItem(
|
||||
title: new Text('Simple dropdown:'),
|
||||
trailing: new DropdownButton<String>(
|
||||
value: dropdown2Value,
|
||||
onChanged: (String newValue) {
|
||||
setState(() {
|
||||
dropdown2Value = newValue;
|
||||
});
|
||||
},
|
||||
items: <String>['One', 'Two', 'Free', 'Four'].map((String value) {
|
||||
return new DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: new Text(value),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user