Flutter

비율 정하기 - AspectRatio

Michelle Hwang 2021. 12. 14. 11:35

https://api.flutter.dev/flutter/widgets/AspectRatio-class.html

 

AspectRatio class - widgets library - Dart API

A widget that attempts to size the child to a specific aspect ratio. The widget first tries the largest width permitted by the layout constraints. The height of the widget is determined by applying the given aspect ratio to the width, expressed as a ratio

api.flutter.dev

AspectRatio 비율 2/1로 주게 되면 가로2 세로 1 비율이 됩니다.  3/2 일시  이미지 가로 450 이면 높이가 450*2/3으로 계산 대략 315가 됩니다. 

 

AspectRatio(
              aspectRatio: 2 / 1,
              child: Image.asset(
                'assets/images/$imageName.jpeg',
                fit: BoxFit.cover,
              )),

 

'Flutter' 카테고리의 다른 글

debug 뱃지가 거슬릴때  (0) 2021.12.15
이미지 모서리 둥글게 만들기 - ClipRRect  (0) 2021.12.14
폰트 적용하기  (0) 2021.12.14
TimePicker 예제  (0) 2021.06.26
DatePicker 예제  (0) 2021.06.26