Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Widget _buildBody(BuildContext context) {
- return StreamBuilder<QuerySnapshot>(
- stream: Firestore.instance.collection("prova").snapshots(),
- builder: (context, snapshot) {
- // if (!snapshot.hasData) return LinearProgressIndicator();
- switch (snapshot.connectionState) {
- case ConnectionState.waiting:
- return new Center(child: new CircularProgressIndicator());
- default:
- return _buildList(context, snapshot.data.documents);
- }
- },
- );
- }
- Widget _buildList(BuildContext context, List<DocumentSnapshot> snapshot) {
- return ListView(
- padding: const EdgeInsets.only(top: 20.0),
- children: snapshot.map((data) => _buildListItem(context, data)).toList(),
- );
- }
- Widget _buildListItem(BuildContext context, DocumentSnapshot data) {
- final record = Record.fromSnapshot(data);
- String name = record.name;
- return Padding(
- key: ValueKey(record.name),
- padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
- child: Container(
- decoration: BoxDecoration(
- border: Border.all(color: Colors.grey),
- borderRadius: BorderRadius.circular(7.0),
- ),
- child: ListTile(
- title: Text(titolo),
- onTap: (){
- Firestore.instance.collection("prova").document(data.documentID.toString()).delete().catchError((e){
- print(e);
- }
- );
- },
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement