您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

设置DropdownButtonFormField列表的高度

设置DropdownButtonFormField列表的高度

我正在检查的代码DropDown没有属性设置的高度Dialog,它几乎填满了整个屏幕。

我对该类进行了一些小的更改,如果需要,您可以将其包含在您的项目中:

https://gist.github.com/tudor07/9f886102f3cb2f69314e159ea10572e1

1-将文件添加到您的项目中。

2-使用别名导入文件,以避免冲突。

 import 'custom_dropdown.dart' as custom;

3-在小部件中使用与DropDown相关的别名,并添加height属性

    Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      body: Container(
          padding: EdgeInsets.fromLTRB(5, 5, 5, 5),
          child: Form(
            child: ListView(
              scrollDirection: Axis.vertical,
              children: <Widget>[
                //other widgets here
                custom.DropdownButtonFormField(
                height: 200.0,
                items: this.dropDownItems),
              ],
            ),
          )),
    );

4-不要忘了在您的别名中添??加别名,DropdownMenuItem如下所示:

 custom.DropdownMenuItem(
                child: Text("Sample Tex"),
                value: "any_value",
              ),
其他 2022/1/1 18:18:07 有478人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶