'I don't want to give height to tabBarview how would i do it?

In below code I don't want give height to tabbarview. I want to give it infinite height means height as per data. when I don't give height to tabbarview it gives me error as follows:

════════ Exception caught by rendering library ═════════════════════════════════ The following assertion was thrown during performResize(): Horizontal viewport was given unbounded height.

Viewports expand in the cross axis to fill their container and constrain their children to match their extent in the cross axis. In this case, a horizontal viewport was given an unlimited amount of vertical space in which to expand. The relevant error-causing widget was TabBarView lib\…\ProductPage\product_type_page.dart:495 When the exception was thrown, this was the stack

Container(
              height: 50,
              decoration: BoxDecoration(
                color: Colors.grey[100],
                border: const Border(
                  top: BorderSide(width: 1, color: 
                        kDefaultBorderColor),
                  bottom: BorderSide(width: 1, color: 
                       kDefaultBorderColor),
                ),
              ),
              child: TabBar(
                controller: _controller,
                indicatorColor: Colors.grey,
                labelColor: kDefaultTitleFontColor,
                labelStyle: TextStyle(
                  fontSize: getProportionateScreenWidth(15.0),
                ),
                tabs: const [
                  Tab(
                    text: 'Description',
                  ),
                  Tab(
                    text: 'Overview',
                  ),
                ],
              ),
            ),

            SizedBox(
              height:MediaQuery.of(context).size.height/2,
              child: TabBarView(controller: _controller, children: [
                ProductDescription(
                  descriptionData: productDetails.typesDescription,
                ),
                ProductDescription(
                  descriptionData: productDetails.typesDescription,
                ),
              ]),
            ),


Solution 1:[1]

There is a property for a container called constraints. Set that property to BoxConstraints.expand(). Also remove the height of the container. Also it would be better if you put TabBar()and TabBarView() which is wrapped with the Expanded() widget inside of a column() widget. So you can remove the SizedBox().

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1