클래스/└ TIL

<TIL> iOS 하단 노치 대응, FutureBuilder 사용시 API 호출 시점

디벅잉 2022. 9. 1. 22:42
728x90

 

🧭

 

Flutter

MediaQuery.of(context).viewPadding.bottom

아이폰 X 이후로 등장한 하단 노치는 높이 값이 34입니다.

플러터에서는 MediaQuery.fo(context).viewPadding.bottom으로 34라는 값을 얻을 수 있습니다.

안드로이드이거나 IOS이더라고 하단 노치가 없다면 위의 값은 0이 됩니다.

하단 노치에 대한 대응으로 SafeArea로 감쌀 수도 있고, 해당 값을 확인해서 따로 여백을 둘 수도 있습니다.

https://medium.com/flutter-community/a-flutter-guide-to-visual-overlap-padding-viewpadding-and-viewinsets-a63e214be6e8

 

A Flutter guide to visual overlap: padding, viewPadding, and viewInsets

Flutter is designed to run to a variety of devices. And to run on multiple devices is to adapt to each device’s quirks and features.

medium.com

https://byunpa.tistory.com/163

 

Solving IOS bottom notch problem in flutter

IOS X모델 이후로, 아이폰에서 bottom notch가 생겨버렸다. 아래쪽은 버튼은 없어지고 notch가 생겼고 위쪽은 M자로 생긴 모델이다. 이러한 모델에서는 OS단 자체에 top and bottom padding이 들어간다. 그래

byunpa.tistory.com

 

 

FutureBuilder

Future<T> 타입의 데이터를 다룰 때 FutureBuilder를 사용하게 됩니다.

API 요청에 따른 응답 결과를 활용하기도 합니다.

이 때 API 요청을 FutureBuilder의 future프로퍼티에 넣게 되면 build시마다 API 요청을 하게 됩니다.

이를 방지하기 위해서 initState 등에서 API 요청을 미리하고,

return되는 Future<T> 데이터를 FutureBuilder의 future 프로퍼티에 넣습니다.

https://stackoverflow.com/questions/58664293/futurebuilder-runs-twice

 

FutureBuilder runs twice

I have problems with FutureBuilder starting twice. First it fetch the data correctly, returning my StartScreen, then after few seconds, the StartScreen rebuilds and I noticed that the FutureBuilder...

stackoverflow.com

 

728x90