import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget { static const String _title = 'Flutter Code Sample';
@override Widget build(BuildContext context) { return MaterialApp( title: _title, home: Scaffold( appBar: AppBar(title: const Text(_title)), body: Center( child: MyStatefulWidget(), ), ), ); } }
class MyStatefulWidget extends StatefulWidget { MyStatefulWidget({Key key}) : super(key: key);
@override _MyStatefulWidgetState createState() => _MyStatefulWidgetState(); }
class _MyStatefulWidgetState extends State { String dropdownValue = 'One';
@override Widget build(BuildContext context) { return DropdownButton( value: dropdownValue, icon: Icon(Icons.arrow_downward), iconSize: 15, elevation: 16, style: TextStyle(color: Colors.deepPurple), underline: Container( height: 2, color: Colors.deepPurpleAccent, ), onChanged: (String newValue) { setState(() { dropdownValue = newValue; }); }, items: ['One', 'Two', 'Free', 'Four'] .map<DropdownMenuItem>((String value) { return DropdownMenuItem( value: value, child: Text(value), ); }).toList(), ); } }