Home > Blockchain >  Expanded in SingleChildScrollView crashes the application
Expanded in SingleChildScrollView crashes the application

Time:09-10

I'm trying to make an application on Flutter. I ran into a problem: I can't make the images stretch in width.

I need 2 columns, each has an image, each column should be 50% of the width of the screen, and stretch image with column. Everything works as shown in the picture, until I insert it into SingleChildScrollView. After that, the application crashes until I set the exact height of the image.

enter image description here

CodePudding user response:

Try flexible instead of expanded

SingleChildScrollView(
              scrollDirection: Axis.vertical,
              child: Row(
                children: [
                  Flexible(
                      child: Image.asset(
                    'assets/images/test.jpeg',
                    fit: BoxFit.contain,
                  )),
                  Flexible(
                      child: Image.asset(
                    'assets/images/test.jpeg',
                    fit: BoxFit.contain,
                  ))
                ],
              ),
            ),
  • Related