본문 바로가기
개발일지

뒷 배경에 이미지를 포함한 위젯 만들기

by 케이오스 2021. 6. 15.

https://stackoverflow.com/questions/45745448/how-do-i-stretch-an-image-to-fit-the-whole-background-100-height-x-100-width

 

Your Question contains the first step, but you need width and height. you can get the width and height of the screen. Here is a small edit

//gets the screen width and height double Width = MediaQuery.of(context).size.width; double Height = MediaQuery.of(context).size.height; Widget background = new Image.asset( asset.background, fit: BoxFit.fill, width: Width, height: Height, ); return new Stack( children: <Widget>[ background, foreground, ], );

You can also use Width and Height to size other objects based on screen size.

ex: width: Height/2, height: Height/2 //using height for both keeps aspect ratio

Share

Improve this answer

Follow

edited Jun 8 '19 at 13:56

 

answered Jun 8 '19 at 13:50

SwiftNinjaPro

5353 silver badges12 bronze badges

Add a comment