最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - How i can set a dropdown menu item dialog width? - Stack Overflow

programmeradmin0浏览0评论
DropdownButtonFormField(
  items: businessType
            .map((businessType) => DropdownMenuItem(
                  value: businessType,
                  child: SizedBox(
                    child: Text(
                      businessType['val'],
                      maxLines: 1,
                      style:
                          TextThemeFile.primary14MediumPoppins(context, 25),
                      softWrap: true,
                      overflow: TextOverflow.ellipsis,
                    ),
                  ),
                ))
            .toList(),
  onChanged: onChanged,
  value: selected,
    hint:hint,
  icon: suffixIcon,
  elevation: 0,
  decoration: InputDecoration(),
)

i want give a margin from the left & right side And menu item show below the dropdown menu as user point of view is not good.In this image dropdownmenu item show at that time dropdown is hide and menu item width is full width

DropdownButtonFormField(
  items: businessType
            .map((businessType) => DropdownMenuItem(
                  value: businessType,
                  child: SizedBox(
                    child: Text(
                      businessType['val'],
                      maxLines: 1,
                      style:
                          TextThemeFile.primary14MediumPoppins(context, 25),
                      softWrap: true,
                      overflow: TextOverflow.ellipsis,
                    ),
                  ),
                ))
            .toList(),
  onChanged: onChanged,
  value: selected,
    hint:hint,
  icon: suffixIcon,
  elevation: 0,
  decoration: InputDecoration(),
)

i want give a margin from the left & right side And menu item show below the dropdown menu as user point of view is not good.In this image dropdownmenu item show at that time dropdown is hide and menu item width is full width

Share Improve this question edited Mar 4 at 13:03 tyg 16.7k4 gold badges39 silver badges49 bronze badges asked Mar 4 at 12:30 Naimish PatelNaimish Patel 8911 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Have you tried adding the following to your DropDownButtonField()

isExpanded: true,
decoration: InputDecoration(
    contentPadding: EdgeInsets.symmetric(horizontal: 16),
  ),

So now your code should look like the following:

DropdownButtonFormField(
  items: businessType
            .map((businessType) => DropdownMenuItem(
                  value: businessType,
                  child: SizedBox(
                    child: Text(
                      businessType['val'],
                      maxLines: 1,
                      style:
                          TextThemeFile.primary14MediumPoppins(context, 25),
                      softWrap: true,
                      overflow: TextOverflow.ellipsis,
                    ),
                  ),
                ))
            .toList(),
  onChanged: onChanged,
  value: selected,
    hint:hint,
  icon: suffixIcon,
  elevation: 0,
  isExpanded: true,
  decoration: InputDecoration(
    contentPadding: EdgeInsets.symmetric(horizontal: 16),
  )
)
发布评论

评论列表(0)

  1. 暂无评论