title: Flutter RenderFlex constraint exception
body: <p>I have a problem. I am trying to put my custom button at the bottom of my screen by using the following code:</p>
  <pre><code>import 'package:test/models/choice_chip_data.dart';
  import 'package:test/page/restaurant_reservation_table_selection.dart';
  import 'package:test/styles/button_style.dart';
  import 'package:test/widgets/reservation_person_selection.dart';
  import 'package:test/widgets/reservation_time_selection.dart';
  import 'package:test/widgets/restaurant_rating.dart';
  import 'package:flutter/material.dart';
  import 'package:intl/intl.dart';
  
  final DateFormat formatter = DateFormat('dd-MM-yyyy');
  
  class RestaurantReservationDetailsPage extends StatefulWidget {
    @override
    _RestaurantReservationDetailsPageState createState() =&gt;
        _RestaurantReservationDetailsPageState();
  }
  
  class _RestaurantReservationDetailsPageState
      extends State&lt;RestaurantReservationDetailsPage&gt; {
    DateTime? reservationDateTime;
  
    @override
    void dispose() {
      super.dispose();
    }
  
    @override
    initState() {
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {    
      return new Scaffold(
          body: SafeArea(
              child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Row(
            children: [
              Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  IconButton(
                    icon: Icon(
                      Icons.arrow_back_ios,
                      color: Colors.black,
                    ),
                    iconSize: 25,
                    onPressed: () {
                      Navigator.pop(context);
                    },
                  ),
                  Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(
                        &quot;Senso Sushi &amp; Grill&quot;,
                        style:
                            TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
                      ),
                      RestaurantRating()
                    ],
                  )
                ],
              )
            ],
          ),
          Container(
            height: 180,
            width: 180,
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(90),
                gradient: LinearGradient(
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                  colors: [
                    Color.fromRGBO(229, 229, 229, 1),
                    Color.fromRGBO(253, 253, 253, 1),
                  ],
                )),
            padding: EdgeInsets.all(20),
            margin: EdgeInsets.only(top: 50, bottom: 50),
            child: Image.asset(
              &quot;assets/restaurant_logo_sample.png&quot;,
            ),
          ),
          Column(
            children: [
              Container(
                  padding: EdgeInsets.only(left: 30, right: 30),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Text(&quot;Aantal personen&quot;,
                          style: TextStyle(
                              color: Color.fromRGBO(0, 0, 0, 0.3), fontSize: 16)),
                      SizedBox(height: 5),
                      CustomNumberInput(),
                      SizedBox(height: 15),
                      Text(&quot;Datum&quot;,
                          style: TextStyle(
                              color: Color.fromRGBO(0, 0, 0, 0.3), fontSize: 16)),
                      SizedBox(height: 5),
                      MainButton(
                          btnText: (reservationDateTime == null
                              ? &quot;Datum kiezen&quot;
                              : formatter.format(reservationDateTime!)),
                          btnAction: () =&gt; {
                                showDatePicker(
                                        context: context,
                                        initialDate: DateTime.now(),
                                        firstDate: DateTime.now(),
                                        lastDate: DateTime.now()
                                            .add(Duration(days: 14)))
                                    .then((date) =&gt; {
                                          setState(() {
                                            reservationDateTime = date;
                                          })
                                        })
                              }),                    
                      Spacer(flex: 1),
                      MainButton(
                          btnText: &quot;Volgende&quot;,
                          btnAction: () =&gt; {
                                Navigator.push(
                                  context,
                                  MaterialPageRoute(
                                      builder: (context) =&gt;
                                          RestaurantReservationTableSelectionPage()),
                                )
                              }),
                    ],
                  )),
            ],
          )
        ],
      )));
    }
  }
  </code></pre>
  <p>I am trying to build the following screen:<br>
  <a href="https://i.stack.imgur.com/Hugur.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hugur.png" alt="enter image description here" /></a></p>
  <p>Now all the elements of that page are on the screen, but the last thing I am trying to do is putting the button to the bottom of the screen. To do that I added the <code>Spacer(flex: 1)</code> on line: 128. Unfortunately, when I run this code, it crashes on a build-in exception in the <code>flex.dart</code> file:
  <a href="https://i.stack.imgur.com/6hhqw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6hhqw.png" alt="enter image description here" /></a></p>
  <p>I have tried setting all the <code>mainAxisSize: MainAxisSize.min</code> of all the <code>Column()</code> widgets, but that still doesn't work...</p>
  <p>Here is the full error output:</p>
  <pre><code>RenderFlex children have non-zero flex but incoming height constraints are unbounded.
  When a column is in a parent that does not provide a finite height constraint, for example if it is in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining space in the vertical direction.
  These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child cannot simultaneously expand to fit its parent.
  Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible children (using Flexible rather than Expanded). This will allow the flexible children to size themselves to less than the infinite remaining space they would otherwise be forced to take, and then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum constraints provided by the parent.
  If this message did not help you determine the problem, consider using debugDumpRenderTree():
    https://flutter.dev/debugging/#rendering-layer
    http://api.flutter.dev/flutter/rendering/debugDumpRenderTree.html
  The affected RenderFlex is:
    RenderFlex#595d0 relayoutBoundary=up5 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE(creator: Column ← Padding ← Container ← Column ← Column ← MediaQuery ← Padding ← SafeArea ← _BodyBuilder ← MediaQuery ← LayoutId-[&lt;_ScaffoldSlot.body&gt;] ← CustomMultiChildLayout ← ⋯, parentData: offset=Offset(0.0, 0.0) (can use size), constraints: BoxConstraints(0.0&lt;=w&lt;=324.0, 0.0&lt;=h&lt;=Infinity), size: MISSING, direction: vertical, mainAxisAlignment: start, mainAxisSize: min, crossAxisAlignment: start, textDirection: ltr, verticalDirection: down)
  The creator information is set to:
    Column ← Padding ← Container ← Column ← Column ← MediaQuery ← Padding ← SafeArea ← _BodyBuilder ← MediaQuery ← LayoutId-[&lt;_ScaffoldSlot.body&gt;] ← CustomMultiChildLayout ← ⋯
  The nearest ancestor providing an unbounded width constraint is: RenderFlex#7c6dc relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:
    creator: Column ← MediaQuery ← Padding ← SafeArea ← _BodyBuilder ← MediaQuery ← LayoutId-[&lt;_ScaffoldSlot.body&gt;] ← CustomMultiChildLayout ← AnimatedBuilder ← DefaultTextStyle ← AnimatedDefaultTextStyle ← _InkFeatures-[GlobalKey#4ac50 ink renderer] ← ⋯
    parentData: offset=Offset(0.0, 0.0) (can use size)
    constraints: BoxConstraints(0.0&lt;=w&lt;=384.0, 0.0&lt;=h&lt;=800.4)
    size: MISSING
    direction: vertical
    mainAxisAlignment: start
    mainAxisSize: min
    crossAxisAlignment: center
    verticalDirection: down
  See also: https://flutter.dev/layout/
  If none of the above helps enough to fix this problem, please don't hesitate to file a bug:
    https://github.com/flutter/flutter/issues/new?template=2_bug.md
  </code></pre>
  <p>What I know so far is that the exception is caused by the <code>Spacer(flex: 1)</code> line. I added that line to add space between the other components and the button, so the button will be moved to the bottom. This is not the case...
  Please let me know how I can fix this!?</p>