I am using a stream builder to fetch some data from Firebase but it's giving me an error
"The body might complete normally causing 'null' to be returned"
although I have provided a return statement where I am returning the 'data table' widget here is my code
StreamBuilder<QuerySnapshot?>(
stream: _firestore.collection('cashOut').snapshots(),
builder: (context, snapshot) {
if (snapshot.hasData) {
List<DataCell> displayedDataCell = [];
for (var item in snapshot.data!.docs) {
displayedDataCell.add(
DataCell(
Text(
item['amount'].toString(),
),
),
);
}
return DataTable(
columns: const <DataColumn>[
DataColumn(
label: Text(
'Date',
),
),
DataColumn(
label: Text(
'Amount',
),
),
DataColumn(
label: Text(
'Optional Detail',
),
),
],
rows: <DataRow>[
DataRow(cells: displayedDataCell),
],
);
}
},
),