Skip to content

Instantly share code, notes, and snippets.

@ashishrawat2911
Last active April 9, 2019 13:57
Show Gist options
  • Select an option

  • Save ashishrawat2911/fdf814c9638976a57d440329a318257f to your computer and use it in GitHub Desktop.

Select an option

Save ashishrawat2911/fdf814c9638976a57d440329a318257f to your computer and use it in GitHub Desktop.
FutureBuilder<List<Person>>(
future: PersonDatabaseProvider.db.getAllPersons(),
builder: (BuildContext context, AsyncSnapshot<List<Person>> snapshot) {
if (snapshot.hasData) {
return ListView.builder(
physics: BouncingScrollPhysics(),
itemCount: snapshot.data.length,
itemBuilder: (BuildContext context, int index) {
Person item = snapshot.data[index];
return Dismissible(
background: Container(color: Colors.red),
onDismissed: (direction) {
PersonDatabaseProvider.db.deletePersonWithId(item.id);
},
child: ListTile(
title: Text(item.name),
subtitle: Text(item.city),
leading: CircleAvatar(child: Text(item.id.toString())),
),
);
},
);
} else {
return Center(child: CircularProgressIndicator());
}
},
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment