Flutter 底部的RenderFlex溢出了41个像素。导致错误的相关小部件在列中被删除

Flutter 底部的RenderFlex溢出了41个像素。导致错误的相关小部件在列中被删除,flutter,dart,Flutter,Dart,我需要创建一个搜索框,其中包含在ListView.Builder中搜索的结果,但我遇到了一个崩溃!我试图通过获取容器高度值MediaQuery.of(context.size.height来解决这个问题,但是得到了同样的问题 ════════ 呈现库捕获到异常═════════════════════ 布局期间抛出了以下断言:底部的RenderFlex溢出了41个像素 导致错误的相关小部件已被删除 Column lib/pages/search.dart:78溢出的RenderFlex的方向为A

我需要创建一个搜索框,其中包含在
ListView.Builder
中搜索的结果,但我遇到了一个崩溃!我试图通过获取
容器
高度值
MediaQuery.of(context.size.height
来解决这个问题,但是得到了同样的问题

════════ 呈现库捕获到异常═════════════════════

布局期间抛出了以下断言:底部的RenderFlex溢出了41个像素

导致错误的相关小部件已被删除 Column lib/pages/search.dart:78溢出的RenderFlex的方向为Axis.vertical。RenderFlex的边缘,即 溢出已在渲染中标记为黄色和黑色 条纹图案。这通常是由于内容太大造成的 对于RenderFlex

考虑将弹性系数(例如,使用扩展的小部件)应用于 强制RenderFlex的子对象适应可用空间 而不是按照他们的自然尺寸。这被认为是一个错误 错误条件,因为它指示存在无法访问的内容 被看见。如果内容合法地大于可用内容 空间,考虑在剪辑之前用clipCt小部件剪辑它。 在flex中,或者使用可滚动的容器而不是flex,如 列表视图

所讨论的特定RenderFlex是:RenderFlex#1a63c relayoutBoundary=up1溢出 ════════════════════════════════════════════════════════════

我的代码:

body: Column(
        children: <Widget>[
          Container(
              width: MediaQuery.of(context).size.width,
              margin: EdgeInsets.all(10),
              padding: EdgeInsets.only(right: 10),
              decoration: BoxDecoration(
                  color: Colors.white,
                  border: new Border.all(
                    color: Colors.grey,
                    width: 1,
                  ),
                  borderRadius: BorderRadius.all(new Radius.circular(10))),
              child: DropdownButton<String>(
                value: dropdownValue,
                icon: Icon(Icons.keyboard_arrow_down),
                iconEnabledColor: Colors.grey,
                iconSize: 50,
                elevation: 16,
                isExpanded: true,
                style: TextStyle(color: Colors.black),
                underline: Container(
                  height: 2,
                ),
                onChanged: (String newValue) {
                  setState(() {
                    dropdownValue = newValue;
                  });
                },
                items: <String>["Swift", "Dart"]
                    .map<DropdownMenuItem<String>>((String value) {
                  return DropdownMenuItem<String>(
                    value: value,
                    child: Text(value),
                  );
                }).toList(),
              )),
          Container(
            margin: EdgeInsets.all(10),
            child: Column(
              children: <Widget>[
                  TextField(
                    obscureText: true,
                    onChanged: (value) {
                      filterSearchResults(value);
                    },
                    decoration: InputDecoration(
                        filled: true,
                        fillColor: Colors.white,
                        focusedBorder: OutlineInputBorder(
                            borderSide: const BorderSide(
                                color: Color.fromRGBO(111, 192, 81, 1),
                                width: 1.5),
                            borderRadius: BorderRadius.circular(10)),
                        contentPadding:
                            EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
                        hintText: "Search",
                        prefixIcon: new Icon(Icons.search, color: Colors.grey),
                        enabledBorder: OutlineInputBorder(
                          borderRadius: BorderRadius.all(Radius.circular(10)),
                          borderSide: BorderSide(width: 1, color: Colors.grey),
                        )),
                  ),
                ListView.builder(
                  shrinkWrap: true,
                  scrollDirection: Axis.vertical,
                  itemCount: items.length,
                  itemBuilder: (context, index) {
                    return ListTile(
                      title: Text('${items[index]}'),
                    );
                  },
                ),
              ],
            ),
          ),
        ],
      ),
body:Column(
儿童:[
容器(
宽度:MediaQuery.of(context).size.width,
保证金:所有(10),
填充:仅限边缘设置(右:10),
装饰:盒子装饰(
颜色:颜色,白色,
边界:新边界(
颜色:颜色。灰色,
宽度:1,
),
borderRadius:borderRadius.all(新半径。圆形(10)),
孩子:下拉按钮(
value:dropdownValue,
图标:图标(图标。键盘箭头向下),
iconEnabledColor:颜色。灰色,
iconSize:50,
海拔:16,
是的,
样式:TextStyle(颜色:Colors.black),
下划线:容器(
身高:2,
),
onChanged:(字符串newValue){
设置状态(){
dropdownValue=newValue;
});
},
物品:[“迅捷”、“飞镖”]
.map((字符串值){
返回下拉菜单项(
价值:价值,
子项:文本(值),
);
}).toList(),
)),
容器(
保证金:所有(10),
子:列(
儿童:[
文本字段(
蒙昧文字:对,
一旦更改:(值){
过滤器搜索结果(值);
},
装饰:输入装饰(
是的,
fillColor:Colors.white,
聚焦顺序:大纲输入边框(
borderSide:const borderSide(
颜色:颜色。来自RGBO(111,192,81,1),
宽度:1.5),
边界半径:边界半径。圆形(10)),
内容填充:
来自LTRB(20.0,15.0,20.0,15.0)的边缘集,
hintText:“搜索”,
前缀:新图标(Icons.search,颜色:Colors.grey),
enabledBorder:OutlineInputBorder(
borderRadius:borderRadius.all(半径圆形(10)),
borderSide:borderSide(宽度:1,颜色:颜色。灰色),
)),
),
ListView.builder(
收缩膜:对,
滚动方向:轴垂直,
itemCount:items.length,
itemBuilder:(上下文,索引){
返回列表块(
标题:文本(“${items[index]}”),
);
},
),
],
),
),
],
),

问题是什么?我如何解决它???

您需要将
扩展的
放在两个地方

body: Column(
  children: <Widget>[
    Container(
      width: MediaQuery.of(context).size.width,
      margin: EdgeInsets.all(10),
      padding: EdgeInsets.only(right: 10),
      decoration: BoxDecoration(
        color: Colors.white,
        border: Border.all(
          color: Colors.grey,
          width: 1,
        ),
        borderRadius: BorderRadius.all(Radius.circular(10)),
      ),
      child: DropdownButton<String>(
        value: dropdownValue,
        icon: Icon(Icons.keyboard_arrow_down),
        iconEnabledColor: Colors.grey,
        iconSize: 50,
        elevation: 16,
        isExpanded: true,
        style: TextStyle(color: Colors.black),
        underline: Container(height: 2),
        onChanged: (String newValue) {
          setState(() {
            dropdownValue = newValue;
          });
        },
        items: <String>["Swift", "Dart"]
            .map<DropdownMenuItem<String>>((String value) {
          return DropdownMenuItem<String>(
            value: value,
            child: Text(value),
          );
        }).toList(),
      ),
    ),
    Expanded(  //TODO: Add Expanded here
      child: Container(
        margin: EdgeInsets.all(10),
        child: Column(
          children: <Widget>[
            TextField(
              obscureText: true,
              onChanged: (value) {
                filterSearchResults(value);
              },
              decoration: InputDecoration(
                filled: true,
                fillColor: Colors.white,
                focusedBorder: OutlineInputBorder(
                  borderSide: const BorderSide(
                    color: Color.fromRGBO(111, 192, 81, 1),
                    width: 1.5,
                  ),
                  borderRadius: BorderRadius.circular(10),
                ),
                contentPadding: EdgeInsets.fromLTRB(20.0, 15.0, 20.0, 15.0),
                hintText: "Search",
                prefixIcon: new Icon(Icons.search, color: Colors.grey),
                enabledBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.all(Radius.circular(10)),
                  borderSide: BorderSide(width: 1, color: Colors.grey),
                ),
              ),
            ),
            Expanded( //TODO: Add Expanded here
              child: ListView.builder(
                shrinkWrap: true,
                scrollDirection: Axis.vertical,
                itemCount: items.length,
                itemBuilder: (context, index) {
                  return ListTile(
                    title: Text('${items[index]}'),
                  );
                },
              ),
            ),
          ],
        ),
      ),
    ),
  ],
)
body:Column(
儿童:[
容器(
宽度:MediaQuery.of(context).size.width,
保证金:所有(10),
填充:仅限边缘设置(右:10),
装饰:盒子装饰(
颜色:颜色,白色,
边界:边界(
颜色:颜色。灰色,
宽度:1,
),
borderRadius:borderRadius.all(半径圆形(10)),
),
孩子:下拉按钮(
value:dropdownValue,
图标:图标(图标。键盘箭头向下),
iconEnabledColor:颜色。灰色,
iconSize:50,
海拔:16,
是的,
样式:TextStyle(颜色:Colors.black),
下划线:容器(高度:2),
onChanged:(字符串newValue){
设置状态(){
dropdownValue=newValue;
});
},
物品:[“迅捷”、“飞镖”]
.map((字符串值){
返回下拉菜单项(
价值:价值,
子项:文本(值),
);
}).toList(),
),
),
扩展(//TODO:Ad)