title: Flutter: adjust height of PageView/Horizontal ListView based on current child
body: <p>I'm trying to create a carousel with items of variable heights. When using PageView or ListView with horizontal scrolling, I need to give it a constant height, like this:</p>
  
  <pre><code>class CarouselVariableHightState extends State&lt;CarouselVariableHight&gt; {
    double height = 200;
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(title: Text('Carousel')),
        body: ListView(
          children: &lt;Widget&gt;[
            Text('My Carousel'),
            Container(
              height: height,
              child: PageView(
                children: &lt;Widget&gt;[
                  _buildCarouselItem(),
                  _buildCarouselItem(),
                  _buildCarouselItem(),
                  _buildCarouselItem(),
                ],
              ),
            ),
            Text('end of List')
          ],
        ),
      );
    }
  
    Widget _buildCarouselItem() {
      return Column(
        children: [
          Container(
            color: Colors.red,
            height: Random().nextInt(200).toDouble(),
            child: Text('Text with random length')
          )
        ]
      );
    }
  }
  </code></pre>
  
  <p>But my items contain text and I don't know the length of it. I don't wan't to limit the height of a CarouselItem because it might cut off the text. How could I have something like a PageView, that adjust its own size based on the currently shown item?</p>
  
  <p>I thought a solution could be to get the height of the CarouselItem and then set it to the height of the PageView. However I couldn't figure out a way to get the height my current Carousel item.</p>
  
  <p>Any Ideas?</p>