0

i am using dropdown button in my project. After clicking dropdownmenubutton it opens the list my items are small (mon.tue,wed and so on) but the dropdown window is expanded till dropdown button. i want to decrease the width of the dropdownMenuitem width withouth changing the width of dropdwon button. I wrapped my dropdownbutton with container and provided the width but its also dreaccesing the width of dropdownbutton. Is there any way that i can only change the width of dropdwonmenu window and keeping isExpanded to true? Thanks in advance.

return Container(
 // width: 300.0,
  child: DropdownButton(
    isExpanded: true,
    value: name,
    items: listOfDropdownMenuItems,
    onChanged: onChanged,
    style: Theme.of(context).textTheme.title,
),

);

Edi
  • 101
  • 1

1 Answers1

0

try using package Dropdown Button 2 DropdownButton2

After import, you can custom the width of dropdown

 dropdownStyleData: DropdownStyleData(
              width: 160,
              padding: const EdgeInsets.symmetric(vertical: 6),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(4),
                color: Colors.redAccent,
              ),
              elevation: 8,
              offset: const Offset(0, 8),
            ),
  • Đức Thành Lê thanks for your response. I don't want to use any 3rd party packages which are not from flutter or flutter favourite , is there any other way to achive that?? – Edi May 28 '23 at 11:13
  • Maybe, you can try to custom your own dropdown, using Overlay entry and stack. Basically, you will have a button , when tap it using overlay entry to mimic/show the dropdown ( which can be a container with custom width and child is a column) – Đức Thành Lê May 29 '23 at 06:43
  • Check this post: https://stackoverflow.com/questions/65685532/create-custom-dropdown-in-flutter-or-how-to-put-custom-dropdown-options-in-a-l – Đức Thành Lê May 29 '23 at 06:45