-
-
Save shameemreza/f82c6d75456fb2fd6d871665e6c42c2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SelectColor extends StatefulWidget { | |
@override | |
_SelectColorState createState() => _SelectColorState(); | |
} | |
class _SelectColorState extends State<SelectColor> { | |
final List<String> _colors = ['Red', 'Green', 'Blue']; | |
String _selectedColor; | |
@override | |
Widget build(BuildContext context) { | |
return Column( | |
children: <Widget>[ | |
DropdownButton( | |
value: _selectedColor, | |
items: _colors.map((String color) { | |
return DropdownMenuItem( | |
value: color, | |
child: Text(color), | |
); | |
}).toList(), | |
onChanged: (value) { | |
setState(() { | |
_selectedColor = value; | |
}); | |
}, | |
), | |
Text('Selected: ${_selectedColor ?? "}'), | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment