A RenderFlex overflowed by 41 pixels on the bottom. The relevant error-causing widget was Column

developer1996

I need to create a search box with the result of searching in ListView.Builder, but I have a crash! I tried to solve it with get the Container height value MediaQuery.of(context).size.height but get me the same issue!

════════ Exception caught by rendering library ═════════════════════

The following assertion was thrown during layout: A RenderFlex overflowed by 41 pixels on the bottom.

The relevant error-causing widget was Column lib/pages/search.dart:78 The overflowing RenderFlex has an orientation of Axis.vertical. The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and black striped pattern. This is usually caused by the contents being too big for the RenderFlex.

Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the RenderFlex to fit within the available space instead of being sized to their natural size. This is considered an error condition because it indicates that there is content that cannot be seen. If the content is legitimately bigger than the available space, consider clipping it with a ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex, like a ListView.

The specific RenderFlex in question is: RenderFlex#1a63c relayoutBoundary=up1 OVERFLOWING ════════════════════════════════════════════════════════════

My Code:

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]}'),
                    );
                  },
                ),
              ],
            ),
          ),
        ],
      ),

What is the issue and how can I solve it??

Crazy Lazy Cat

You need to place Expanded in two places

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]}'),
                  );
                },
              ),
            ),
          ],
        ),
      ),
    ),
  ],
)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

A RenderFlex overflowed by 117 pixels on the bottom. The relevant error-causing widget was: Column

A RenderFlex overflowed by 4.8 pixels on the bottom. The relevant error-causing widget was Column

Alert Dialog widget is causing A RenderFlex overflowed by 92 pixels on the bottom

Error : A RenderFlex overflowed by 99524 pixels on the bottom

A RenderFlex overflowed by Infinity pixels on the bottom

A RenderFlex overflowed by 620 pixels on the bottom

A RenderFlex overflowed by 112 pixels on the bottom

A RenderFlex overflowed by 128 pixels on the bottom

A RenderFlex overflowed by 103 pixels on the bottom

A RenderFlex overflowed by 99888 pixels on the bottom

Flutter layout error 'A RenderFlex overflowed by Infinity pixels on the bottom'

Flutter TextField Error: A RenderFlex overflowed by 99472 pixels on the bottom

How to fix "A RenderFlex overflowed by Infinity pixels on the bottom." error on flutter?

A RenderFlex overflowed by 58 pixels on the bottom: Error in List Tile flutter

Animated container : RenderFlex overflowed by 154 pixels on the bottom

Flutter/Dart - A RenderFlex overflowed by 99804 pixels on the bottom

Flutter - A RenderFlex overflowed by 5.4 pixels on the bottom

A RenderFlex overflowed by 260 pixels on the bottom. - ListTile

Flutter: A RenderFlex overflowed by 14 pixels on the bottom

Flutter - A RenderFlex overflowed by 190 pixels on the bottom in showModalBottomSheet

Flutter A RenderFlex overflowed by 46 pixels on the bottom

Flutter: A RenderFlex overflowed by 13 pixels on the bottom

Flutter app - "A RenderFlex overflowed by..." and widget bottom

Flutter: How to fix "A RenderFlex overflowed by pixels " error?

flutter error: A RenderFlex overflowed by 1088 pixels on the right

SingleChildScrollView with Column of Flexible Cards: "A RenderFlex Overflowed by x pixels on bottom", How to make card expand?

The relevant error-causing widget was Column | flutter

Why can't I scroll over a listView? I get the typic error `A RenderFlex overflowed by xx pixels on the bottom`

carousel slider "A RenderFlex overflowed by Infinity pixels on the bottom." flutter