title: Flutter dynamic height of ListView
body: <p>I am developing a <strong>Flutter</strong> application and I want to dynamically adjust the height of the ListView.</p>
  
  <p>I want the list to have a maximum height of <code>200</code>. If the height is more than that, user will have to scroll to reach the bottom. If height is below <code>200</code>, it will take only as much space as needed.</p>
  
  <p>Preview of application: <a href="https://i.stack.imgur.com/Q0bgD.png" rel="noreferrer">Screenshot</a>. As you can see <code>Restaurants nearby</code> is pushed to the very bottom of the page. I want the ListView to only take height of <code>200</code> or less so that the content below isn't pushed to the bottom.</p>
  
  <p>Here is my current code:</p>
  
  <pre><code>@override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(10.0),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: &lt;Widget&gt;[
          Text(
            'Restaurants nearby',
            style: TextStyle(
              fontSize: 20.0,
              fontWeight: FontWeight.bold,
            ),
          ),
          Divider(),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: &lt;Widget&gt;[
              RaisedButton(
                child: Text('Enter restaurant manually'),
                onPressed: () {
                  print('Button pressed');
                },
              ),
            ],
          ),
          Flexible(
            child: ListView.builder(
              itemBuilder: (BuildContext context, int index) {
                return ListTile(
                  leading: CircleAvatar(
                    backgroundColor: Colors.cyan,
                  ),
                  title: Text('Test restaurant'),
                  subtitle: Text('80m'),
                );
              },
              itemCount: 15,
            ),
          ),
          Text(
            'Restaurants nearby',
            style: TextStyle(
              fontSize: 20.0,
              fontWeight: FontWeight.bold,
            ),
          ),
        ],
      ),
    );
  }
  </code></pre>