UI 개발 중에 위치를 Padding 처리를 직접하고 싶을 때 사용하기에 좋다.
double getScreenWidth(BuildContext context) => MediaQuery.of(context).size.width;
double getScreenHeight(BuildContext context) => MediaQuery.of(context).size.height;
double getStatusBarSize(BuildContext context) => MediaQuery.of(context).padding.top;
double getPixelRatio(BuildContext context) => MediaQuery.of(context).devicePixelRatio;
/*
// Full screen width and height
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
// Height (without SafeArea)
var padding = MediaQuery.of(context).padding;
double height1 = height - padding.top - padding.bottom;
// Height (without status bar)
double height2 = height - padding.top;
// Height (without status and toolbar)
double height3 = height - padding.top - kToolbarHeight;
*/
'프로그래밍 > Flutter' 카테고리의 다른 글
[Flutter] 날씨 정보 받아오기(weather, geolocator) (0) | 2022.05.02 |
---|---|
[Flutter] 난독화 (0) | 2022.04.28 |
[Flutter] Screen Orientation (0) | 2022.04.27 |
[Flutter] 카카오 로그인 설정 (0) | 2022.04.23 |
[Flutter] StatusBar Color (0) | 2022.04.21 |
댓글