Flutter- Vertical viewport was given unbounded height

In flutter development, Maybe you've seen this type of error "Vertical viewport was given unbounded height". What is the reason behind that you got this error because you have added the ListView or GridView inside the Column without giving proper constraint. So ln this post I will give you solution, How to solve this type of error quickly.

Error :

══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞══════════════
The following assertion was thrown during performResize():
Vertical viewport was given unbounded height.
Viewports expand in the scrolling direction to fill their container. In this case, a vertical
viewport was given an unlimited amount of vertical space in which to expand. This situation
typically happens when a scrollable widget is nested inside another scrollable widget.

Let's see all possible solutions one by one of Vertical viewport was given unbounded height error.

 

Solutions :

1. Use Shrinkwrap: true on ListVew() Widget :

We need to set the Shrinkwrap properties True of the Listview Widget like below.

Column(
  children: [
    ListView(
      shrinkWrap: true,
      children: const <Widget>[
         Text("Errorgram")],
    ),
  ],
)

 

2. Using  Sizebox or Container :

We need to give height to SizedBox, you can see the below example.

 Column(
        children: [
          SizedBox(
            height: 300,
            child: ListView(
              children: [
                Text("Errorgram"),
              ],
            ),
          )
        ],
      )

 

We need to give height to Container, you can see the below example.

Column(
        children: [
          Container(
            height: 300,
            child: ListView(
              children: [
                Text("Errorgram"),
              ],
            ),
          )
        ],
      )

 

3. Using Expanded Widget :

Column(
        children: [
          Expanded(
              child: ListView(
            children: [
              Text("Errorgram"),
            ],
          ))
        ],
      )

We can solve easily "Vertical viewport was given unbounded height" above way. I hope this post will help you

Tags: