Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class SelectColor extends StatefulWidget {
_SelectColorState createState() => _SelectColorState();
class _SelectColorState extends State<SelectColor> {
final List<String> _colors = ['Red', 'Green', 'Blue'];
String _selectedColor;
Widget build(BuildContext context) {
return Column(
children: <Widget>[
value: _selectedColor,
items: color) {
return DropdownMenuItem(
value: color,
child: Text(color),
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