Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

BoxConstraints forces an infinite height[error]

This is my code..
I am getting error saying that ‘BoxConstraints forces an infinite height.’ and then a description and i am new to flutter i am not getting a way to solve this.

  body:SingleChildScrollView(
    child: Stack(
      fit: StackFit.expand,
      children: [
        Image(
          color: Colors.black12,
          colorBlendMode: BlendMode.darken,
          image: AssetImage('images/Alone.jpg'),
          fit: BoxFit.cover,
        ),
        Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Show('Alone is Stronger', 'y'),
          ],
        )
      ],
    ),
  ),

This is my Show widget.

Widget Show(String x,String y){
return
    Container(
    margin: EdgeInsets.fromLTRB(10, 5, 10, 2),
    width: 400,
    decoration: BoxDecoration(
      color: Colors.white10,
      borderRadius: BorderRadius.circular(10),
    ),
    padding: EdgeInsets.all(10),
    child: Text(
      '$x',
          style: TextStyle(
        fontSize: 20,
         fontWeight: FontWeight.bold,
      color: Colors.yellowAccent,
           ),
        ),
     ); 
  }

Lot of questions already here with same problem but i am not getting where the problem is.
Thanks in advance

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

From your code-snippet, I can understand you are trying to have a background on body.

SingleChildScrollView provide infinite height and while Stack is its child and use parent size, it will get infinite height and through errors.

In your case, the widget structure will be

  body: Stack(
        fit: StackFit.expand,
        children: [
          Image(
            color: Colors.black12,
            colorBlendMode: BlendMode.darken,
            image: AssetImage('images/Alone.jpg'),
            fit: BoxFit.cover,
          ),
          SingleChildScrollView(
              child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Show('Alone is Stronger', 'y'),
            ],
          ))
        ],
      ),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading