future builder inside listview code example
Example 1: future builder snapshot list
FutureBuilder(
future: _fetchListItems(),
builder: (context, AsyncSnapshot snapshot) {
if (!snapshot.hasData) {
return Center(child: CircularProgressIndicator());
} else {
Container(
child: ListView.builder(
itemCount: snapshot.data.length,
scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context, int index) {
return Text('${snapshot.data[index].title}');
}));
}
});
Example 2: future builder flutter
Example of future function:Future getProjectDetails() async { List<ProjectModel> projetcList = await someFutureCall(); return projetcList; }