개발일지
뒷 배경에 이미지를 포함한 위젯 만들기
케이오스
2021. 6. 15. 01:15
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
Follow
answered Jun 8 '19 at 13:50
5353 silver badges12 bronze badges
- 2
- fit: BoxFit.fill, on Image was a life saver, thanks :) – STEEL Aug 25 '20 at 11:07