-
-
Save Rahiche/c60460cb2c07c150d14e9adef64c378c to your computer and use it in GitHub Desktop.
This file contains 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
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(title: Text("Flutter SQLite")), | |
body: FutureBuilder<List<Client>>( | |
future: DBProvider.db.getAllClients(), | |
builder: (BuildContext context, AsyncSnapshot<List<Client>> snapshot) { | |
if (snapshot.hasData) { | |
return ListView.builder( | |
itemCount: snapshot.data.length, | |
itemBuilder: (BuildContext context, int index) { | |
Client item = snapshot.data[index]; | |
return ListTile( | |
title: Text(item.lastName), | |
leading: Text(item.id.toString()), | |
trailing: Checkbox( | |
onChanged: (bool value) { | |
DBProvider.db.blockClient(item); | |
setState(() {}); | |
}, | |
value: item.blocked, | |
), | |
); | |
}, | |
); | |
} else { | |
return Center(child: CircularProgressIndicator()); | |
} | |
}, | |
), | |
floatingActionButton: FloatingActionButton( | |
child: Icon(Icons.add), | |
onPressed: () async { | |
Client rnd = testClients[math.Random().nextInt(testClients.length)]; | |
await DBProvider.db.newClient(rnd); | |
setState(() {}); | |
}, | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment