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

Flutter- Stack takes a lot of height despite the children

I’m using Listview.builder to show products.
I use mediaQuery to check if screen width is big enough then it would use Grideview.builder() as show in image below but there is a problem with Grideview.builder() only which is this excees Stack Height, i checked with flutter devTools and found the the column inside stack is just taking it min size so what causes stack to be this big?

child: Stack(
    children: [
      Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          // Work Image
          AspectRatio(
            aspectRatio: 16.0 / 9.0,
            child: Image.asset(
              Constants.appLogo,
              fit: BoxFit.cover,
            ),
          ),
          Padding(
            padding: const EdgeInsets.only(
              left: Sizes.PADDING_18,
              bottom: Sizes.PADDING_8,
              right: Sizes.PADDING_8,
            ),
            // Work Title, Adress
            child: Row(
              children: [
                Flexible(
                  child: Text(
                    testAdress.length > 25
                        ? '${testAdress.substring(0, 25)}...'
                        : testAdress,
                    overflow: TextOverflow.ellipsis,
                    maxLines: 1,
                    style: const TextStyle(
                      fontWeight: FontWeight.w600,
                      fontSize: Sizes.TEXT_SIZE_22,
                    ),
                  ),
                ),
              ],
            ),
          ),
          Padding(
            padding: const EdgeInsets.only(
              left: Sizes.PADDING_18,
              bottom: Sizes.PADDING_8,
              right: Sizes.PADDING_8,
            ),
            //SubTitle
            child: Row(
              children: [
                Flexible(
                  child: FittedBox(
                    fit: BoxFit.scaleDown,
                    alignment: Alignment.bottomLeft,
                    child: Text(
                      testAdress.length > 34
                          ? '${testAdress.substring(0, 34)}...'
                          : testAdress,
                      overflow: TextOverflow.ellipsis,
                      maxLines: 1,
                      style: TextStyle(
                        fontSize: Sizes.TEXT_SIZE_14,
                        color: Colors.grey.withOpacity(0.8),
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
          ],
        ),
      ),
    ],
  ),

enter image description here

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 :

Default childAspectRatio:1 on gridView, you can set childAspectRatio: 16.0 / 9.0

   childAspectRatio: 16.0 / 9.0,
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