Last active
April 9, 2019 13:57
-
-
Save ashishrawat2911/fdf814c9638976a57d440329a318257f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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