Future 함수(로직)을 바로 UI(위젯)으로 변환하는 위젯
FutureBuilder(
future: http.get('http://awesome.data'),
builder: (context, snapshot) {
return AwesomeData(snapshot.data);
}
)
FutureBuilder(
future: http.get('http://awesome.data'),
builder: (context, snapshot) {
if(snapshot.connectionState == ConnectionState.done) {
return AwesomeData(snapshot.data);
} else {
return CircularProgressIndicator();
}
}
)
// ConnectionState.none;
// ConnectionState.waiting;
// ConnectionState.active;
// ConnectionState.done;
if(snapshot.connectionState == ConnectionState.done) {
if(snapshot.hasError) {
return SomethingWentWrong();
}
...
}