class Logs extends StatefulWidget {
const Logs({
Key key,
}) : super(key: key);
@override
State<Logs> createState() => _LogsState();
}
class _LogsState extends State<Logs> {
String userId;
userId = firebaseUser.uid;
@override
Widget build(BuildContext context) {
return StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance.collection(userId).snapshots(),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasError) {
print('Something went Wrong');
}
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: CircularProgressIndicator(),
);
}
final List storedocs = [];
snapshot.data.docs.map((DocumentSnapshot document) {
Map a = document.data() as Map<String, dynamic>;
storedocs.add(a);
a['id'] = document.id;
}).toList();
var n = storedocs.length;
return Scaffold(
appBar: AppBar(
title: Text("Smart Electric"),
foregroundColor: Colors.white,
backgroundColor: Colors.yellow[600]),
body: Container(
children: <Widget>[
if (storedocs.isEmpty) ...{
Text(" No readings Received yet"),
} else ...{
for (int i = 0; i < n; i++) ...[
// if (storedocs[i]['UserId'] == userId) ...{
logss(storedocs[i]['Units'],
storedocs[i]['Time'].toDate(), storedocs[i]['id']),
// }
],
}
],
),
),
),
);
});
}
}
════════ Exception caught by widgets library ═══════════════════════════════════
The getter 'isNotEmpty' was called on null. Receiver: null Tried calling: isNotEmpty
Following is the exception which is being caught,what thing is causing this exception?