'how to make dropdown list#flutter

how to make dropdown list when on tap on button with out using dropdown button #flutterenter image description here

new DropdownButton(
  value: _selectedLocation,
  onChanged: (String newValue) {
    setState(() {
      _selectedLocation = newValue;
     });
},
items: _locations.map((String location) {
  return new DropdownMenuItem<String>(
     child: new Text(location),
  );
}).toList(),


Solution 1:[1]

Try below code hope its helpful to you . you must used dropdown_below from here, Refer my answer here also for same

Create your list:

 List mobileList = [
    {'no': 1, 'mobile': 'Apple'},
    {'no': 2, 'mobile': 'Google'},
    {'no': 3, 'mobile': 'Samsung'},
    {'no': 4, 'mobile': 'Sony'},
    {'no': 5, 'mobile': 'LG'},
  ];

One varibale and list our value

List<DropdownMenuItem<Object?>> _dropdownTestItems = [];
  var selectedmobile;

Create initState() and dispose() method:

  @override
  void initState() {
    _dropdownTestItems = buildDropdownTestItems(mobileList);
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

Add your selected gender value in dropdown

  List<DropdownMenuItem<Object?>> buildDropdownTestItems(List mobileList) {
    List<DropdownMenuItem<Object?>> items = [];
    for (var i in mobileList) {
      items.add(
        DropdownMenuItem(
          value: i,
          child: Text(
            i['mobile'],
            style: TextStyle(color: Colors.black),
          ),
        ),
      );
    }
    return items;
  }

Your Widget:

  Padding(
        padding: const EdgeInsets.all(8.0),
        child: DropdownBelow(
          itemWidth: 150,
          itemTextstyle: TextStyle(
              fontSize: 14,
              fontWeight: FontWeight.w400,
              color: Colors.black),
          boxTextstyle: TextStyle(
              fontSize: 14,
              fontWeight: FontWeight.w400,
              color: Colors.white54),
          boxPadding: EdgeInsets.fromLTRB(13, 12, 13, 12),
          boxWidth: 150,
          boxHeight: 45,
          boxDecoration: BoxDecoration(
            color: Colors.transparent,
            border: Border.all(
              width: 1,
              color: Colors.black,
            ),
          ),
          icon: Icon(
            Icons.arrow_downward,
            color: Colors.black,
          ),
          hint: Text(
            'Select Mobile',
            style: TextStyle(
              color: Colors.black,
            ),
          ),
          value: selectedmobile,
          items: _dropdownTestItems,
          onChanged: (selectedTest) {
            setState(() {
              selectedmobile = selectedTest;
            });
          },
        ),
      ),
   

Your Result Screen-> image

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ravindra S. Patil