title: How to pass multiple widgets as children in Flutter?
body: <p>I recently started learning Flutter and have been going through the documentation. I am working on this small app, where the screen has a button on the top of the screen and a list below it. </p>
  
  <p>Whenever I pass <code>RaisedButton</code> with a <code>ListView</code> widget into another <code>ListView</code> or <code>Column</code> Widget, its throwing error.</p>
  
  <pre><code>I/flutter ( 4734): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
  I/flutter ( 4734): The following assertion was thrown during performResize():
  I/flutter ( 4734): Vertical viewport was given unbounded height.
  I/flutter ( 4734): Viewports expand in the scrolling direction to fill their container.
  ////MORE LINES OF ERRORS/////
  </code></pre>
  
  <p>Here's the code I have been working on:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  void main() {
    runApp(ListDemo(
      items: new List&lt;ListItem&gt;.generate(
        100,
            (i) =&gt; i % 6 == 0
            ? new HeadingItem("Heading $i")
            : new MessageItem("Sender $i", "Message body $i"),
      ),
    ));
  }
  
  // The base class for the different types of items the List can contain
  abstract class ListItem {}
  
  // A ListItem that contains data to display a heading
  class HeadingItem implements ListItem {
    final String heading;
  
    HeadingItem(this.heading);
  }
  
  // A ListItem that contains data to display a message
  class MessageItem implements ListItem {
    final String sender;
    final String body;
  
    MessageItem(this.sender, this.body);
  }
  
  class ListDemo extends StatelessWidget {
    final List&lt;ListItem&gt; items;
    ListDemo({Key key, @required this.items}) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
  
      final ListView listView = ListView.builder(
        itemCount: items.length,
        itemBuilder: (context, index) {
          final item = items[index];
  
          if (item is HeadingItem) {
            return new ListTile(
              title: new Text(
                item.heading,
                style: Theme.of(context).textTheme.headline,
              ),
            );
          } else if (item is MessageItem) {
            return new ListTile(
              title: new Text(item.sender),
              subtitle: new Text(item.body),
            );
          }
        },
      );
  
      return MaterialApp(
        home: Scaffold(
          appBar: AppBar(
            title: Text('Lists'),
          ),
          body: ListView( //Tried using ListView, Column.. None of them help solving the issue
            children: &lt;Widget&gt;[
              RaisedButton(
                onPressed: null,
                child: Text('Sample Button'),
              ),
              Container(
                child: listView,
              )
          ]
        )
        )
      );
    }
  }
  </code></pre>
  
  <p>Please help me solve this issue of letting know, how to pass multiple children, and also please make understand the concept as well.</p>
  
  <p><strong>EDITED</strong></p>
  
  <p>One of the possible solutions suggested wrapping <code>ListView</code> with <code>Expanded</code> class. When I did it threw me an error as below:</p>
  
  <pre><code>I/flutter ( 4190): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
  I/flutter ( 4190): The following assertion was thrown building NotificationListener&lt;KeepAliveNotification&gt;:
  I/flutter ( 4190): Incorrect use of ParentDataWidget.
  I/flutter ( 4190): Expanded widgets must be placed inside Flex widgets.
  I/flutter ( 4190): Expanded(no depth, flex: 1, dirty) has no Flex ancestor at all.
  </code></pre>
  
  <p>So I wrapped the entire Widget code in <code>Flex</code> as below:</p>
  
  <pre><code>      Flex(
          direction: Axis.vertical,
          children: &lt;Widget&gt;[
            ListView(
              children: &lt;Widget&gt;[
                RaisedButton(
                 onPressed: null,
                 child: Text('Snackbar'),
                ),
                Expanded(
                 child: listView
                )
               ],
              )
            ],
          )
  </code></pre>
  
  <p>but then it threw me this error:</p>
  
  <pre><code>I/flutter ( 4388): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
  I/flutter ( 4388): The following assertion was thrown during performResize():
  I/flutter ( 4388): Vertical viewport was given unbounded height.
  I/flutter ( 4388): Viewports expand in the scrolling direction to fill their container.In this case, a vertical
  I/flutter ( 4388): viewport was given an unlimited amount of vertical space in which to expand. This situation
  I/flutter ( 4388): typically happens when a scrollable widget is nested inside another scrollable widget.
  </code></pre>