Get parent widget height in flutter

Viewed 3901

I want create statefulWidget and want in this widget get parent widget height. Don't want do this by sending height data from parent widget. How can I do this?

1 Answers

Use LayoutBuilder as a child widget.

LayoutBuilder(builder: (ctx, constraints) {
      return 
          Container(
            height: constraints.maxHeight * 0.5,
            width: constraints.maxWidth * 0.5,
            child: Text('Inside Layout Builder'),
     );
  })

As per this code Container will use half of the height and width of parent widget.

Related