android - 如何使菜单出现在 flutter 的下拉菜单按钮下方

标签 android flutter dart user-interface drop-down-menu

我设置了 menuMaxHeight 因为它占用了很多屏幕。
我的菜单出现在菜单按钮上方。
这是小部件

DropdownButtonHideUnderline(
      child: DropdownButton<String>(
        menuMaxHeight: 300,
        //isDense: true,
        hint: Text("State",style: TextStyle(color: Color(0xFF8B8B8B),fontSize: 15),),
        //alignment: Alignment.bottomLeft,
        value: stateValue,
       // elevation: 2,
       //underline: null,
       isExpanded: true,
       style: const TextStyle(color: Colors.black),
        onChanged: (String? newValue) {
          setState(() {
            stateValue = newValue!;
          });
        },
        items: <String>['AL' ,'AK' ,'AZ' ,'AR' ,'CA' ,'CZ' ,'CO' ,'CT' ,'DE' ,'DC' ,'FL' ,'GA' ,'GU' ,'HI' ,'ID' ,'IL' ,'IN' ,'IA' ,'KS' ,'KY' ,'LA' ,'ME' ,'MD' ,'MA' ,'MI' ,'MN' ,'MS' ,'MO' ,'MT' ,'NE' ,'NV' ,'NH' ,'NJ' ,'NM' ,'NY' ,'NC' ,'ND' ,'OH' ,'OK' ,'OR' ,'PA' ,'PR' ,'RI' ,'SC' ,'SD' ,'TN' ,'TX' ,'UT' ,'VT' ,'VI' ,'VA' ,'WA' ,'WV' ,'WI' ,'WY' ,'null']
            .map<DropdownMenuItem<String>>((String value) {
          return DropdownMenuItem<String>(
            value: value,
            child: Text(value),
          );
        }).toList(),
      ),
    ),
  ),
)

有没有办法让菜单出现在按钮下方。我看过文档,但无法找到解决方法。谢谢!

最佳答案

你可以使用 DropdownButton2 来实现。 .它基于 Flutter 的核心 DropdownButton,按钮下方有稳定的下拉菜单,还有许多其他选项可以根据您的需要进行自定义。
免责声明:我是上面提到的包的作者。

关于android - 如何使菜单出现在 flutter 的下拉菜单按钮下方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70957361/

相关文章:

android - 可能通过 InterationListener 从适配器调用 Intent

android - 为亚马逊构建一个未签名的 apk,为谷歌构建一个签名的 apk

mysql - Flutter SQFLite Assets 数据库

dart - Flutter Firestore 使设备上的 runTransaction 瞬间完成

Flutter 状态栏动态改变颜色

javascript - React native android 应用程序已停止

android - 在Android中编辑声音文件

regex - TextField在whitelistingtextinputformatter中添加2个十进制正数配置后不接受输入

facebook - 无法使用 flutter with firebase 从 Facebook 注销

flutter - 无法将类型 'Iterable<Food>' 的值分配给类型 'List<Food>' 的变量