-
Notifications
You must be signed in to change notification settings - Fork 0
/
Home.dart
103 lines (88 loc) · 3.52 KB
/
Home.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
class Clientes extends StatefulWidget {
@override
_ClientesState createState() => _ClientesState();
}
class _ClientesState extends State<Clientes> {
Future getClientes() async {
var firestore = Firestore.instance;
QuerySnapshot qn = await firestore.collection("clientes").getDocuments();
return qn.documents;
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
backgroundColor: Colors.blue,
actions: <Widget>[
Padding(
padding: EdgeInsets.only(right: 15),
child: Icon(Icons.search),
)
],
title: Center(
child: Text("Clientes"),
)),
body: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
SizedBox(
height: 10,
),
Expanded(
child: FutureBuilder(
future: getClientes(),
builder: (_, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return new Center(
child: CircularProgressIndicator(),
);
} else {
return ListView.builder(
shrinkWrap: true,
itemCount: snapshot.data.length,
itemBuilder: (_, index) {
return Container(
height: 60,
margin: EdgeInsets.fromLTRB(20, 0, 20, 15),
decoration: BoxDecoration(
gradient: LinearGradient(
stops: [0.015, 0.015],
colors: [Colors.purple, Colors.purple],
),
borderRadius: BorderRadius.all(
Radius.circular(5.0),
),
),
child: Card(
child: ListTile(
title: Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(snapshot.data[index].data["nome"]),
Text(snapshot
.data[index].data["telefone"]),
],
),
leading: CircleAvatar(
backgroundColor: Colors.white,
child: Image.network(
"https://cdn2.iconfinder.com/data/icons/ios-7-icons/50/user_male2-128.png"),
),
),
),
);
});
}
}),
),
)
],
)),
);
}
}