DropdownButtonHideUnderline in flutter code example

Example: dropdownbuttonhideunderline beautiful in flutter

import 'package:flutter/material.dart';void main() => runApp(MaterialApp(      title: "Tutorial",      home: Home(),    ));class Home extends StatefulWidget {  @override  _HomeState createState() => _HomeState();}class _HomeState extends State<Home> {  List<ListItem> _dropdownItems = [    ListItem(1, "First Value"),    ListItem(2, "Second Item"),    ListItem(3, "Third Item"),    ListItem(4, "Fourth Item")  ];  List<DropdownMenuItem<ListItem>> _dropdownMenuItems;  ListItem _selectedItem;  void initState() {    super.initState();    _dropdownMenuItems = buildDropDownMenuItems(_dropdownItems);    _selectedItem = _dropdownMenuItems[0].value;  }  List<DropdownMenuItem<ListItem>> buildDropDownMenuItems(List listItems) {    List<DropdownMenuItem<ListItem>> items = List();    for (ListItem listItem in listItems) {      items.add(        DropdownMenuItem(          child: Text(listItem.name),          value: listItem,        ),      );    }    return items;  }  @override  Widget build(BuildContext context) {    return Scaffold(      appBar: AppBar(        title: Text("Dropdown Button"),      ),      body: Container(        padding: EdgeInsets.all(20.0),        child: DropdownButton<ListItem>(            value: _selectedItem,            items: _dropdownMenuItems,            onChanged: (value) {              setState(() {                _selectedItem = value;              });            }),      ),    );  }}

Tags:

Misc Example