Flutter 개발 Story
Future 본문
Future
Future란 Flutter에서 미래에 요청한 데이터나 에러를 담을 박스를 의미한다.
데이터나 에러중 어느 것이 나올지 모르므로 두 가지 경우를 모두 대비한 함수를 구현해야한다.
then - 데이터가 나올 경우
catchError - 에러가 나올 경우
예)
futureNumber()는 데이터 타입이 Future<int>이다. 즉, 미래에 요청할 데이터 타입이 int인 것이다.
결과에서 "기다리는 중" 이 먼저 나온 이유는 비동기이기 때문이다.
참고 - velog.io/@jintak0401/FlutterDart-%EC%97%90%EC%84%9C%EC%9D%98-Future-asyncawait
'Flutter' 카테고리의 다른 글
StateManagement(InheritedWidget, Provider) (0) | 2021.04.15 |
---|---|
Gradle exception 에러 (0) | 2021.04.05 |
A RenderFlex overflowed by ~ pixels on the bottom. (0) | 2021.02.17 |
Flutter 기본_isolate (0) | 2021.02.15 |
Flutter 기본_ListView2 (0) | 2021.02.15 |
Comments