Blog

[Flutter] FutureBuilder

Published 1 min read

It's a widget for displaying a widget received through a Future.
Its arguments are future and builder.

If you pass a function that returns a Future to the future argument,
inside builder you can get the widget returned by that function through snapshot.data.

FutureBuilder( future: getMedicine(itemName: "타이레ㅇㄹ놀", idx: 0), builder: (BuildContext context, AsyncSnapshot snapshot) { //This part runs when the data hasn't been received yet. if (snapshot.hasData == false) { return const CircularProgressIndicator(); } //The part returned when an error occurs else if (snapshot.hasError) { return Widget; } // When the data is received normally, this part runs. else { return Widget; } }, ),

Comments

Leaving a comment stores your nickname (or GitHub profile info). Privacy policy

GitHub