How we can create DataTable from Firestore collection and keep only one column on the top of ListView ?, with below code column is present for each row, also if the collection contain 1000 docs the column should not be hidden when user scoll
Below is my code:
@override
Widget build(BuildContext context) {
return FirestoreQueryBuilder<Map<String, dynamic>>(
pageSize: 5,
query: FirebaseFirestore.instance.collection('users'),
builder: (context, snapshot, _) {
return ListView.builder(
scrollDirection: Axis.vertical,
itemCount: snapshot.docs.length,
itemBuilder: (context, index) {
if (snapshot.hasMore && index + 1 == snapshot.docs.length) {
snapshot.fetchMore();
}
final user = snapshot.docs[index].data();
return DataTable(
columns: const <DataColumn>[
DataColumn(
label: Text('User Name'),
),
DataColumn(
label: Text('User email'),
),
DataColumn(
label: Text('User Id'),
),
],
rows: [
DataRow(
cells: [
DataCell(
Text(user['name']),
),
DataCell(
Text(user['email']),
),
DataCell(
Text(user['id']),
),
],
),
],
);
},
);
},
);
}
NOTE : I'm using flutterfire_ui to paginate collection
Thanks