0

Can We wrap DecorationImage with SingleChildScrollView or any other property to pass offset to image !

2 Answers2

0

The need of SingleChildScrollView is to make the content inside it be scrollable. Since I don't see your code, I assumed that maybe a BoxFit.cover will solve your problem. Here's my code:

Container(
                  width: 50,
                  height: 50,
                  decoration: const BoxDecoration(
                    image: DecorationImage(
                      image: AssetImage('your image here'),
                      fit: BoxFit.cover,
                    ),
                  ),
                ),

The BoxFit.cover makes your image fill the container. It means that the container -with it's own width and height- will be fully filled by the images ignoring the images resolution ratio. It'll be like putting a 50cm square frame above a A3 image poster. The poster will fill the square. Just try my code and experiment it. Ow, and btw, I know that your name is Harsh, but you don't need to be harsh by asking a question with an exclamation mark. ;)

0

SingleChildScrollView Widget is basically used to achieve scroll functionality in screen. If you want to scroll among the images then you can wrap with this widget. Else for a single image you don't need to wrap with SingleChildScrollView widget. Hope you understand.

Vishal_VE
  • 1,852
  • 1
  • 6
  • 9