import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
class Edit extends StatefulWidget {
@override
_EditState createState() => _EditState();
}
class _EditState extends State<Edit> {
@override
Widget build(BuildContext context) {
CollectionReference users= FirebaseFirestore.instance
.collection('users')
.doc(FirebaseAuth.instance.currentUser.email)
.collection('expense');
return StreamBuilder<QuerySnapshot>(
stream: users.snapshots(),
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
// print(snapshot.data.docs.length);
if(snapshot.hasError) {
return CircularProgressIndicator();
}
return ListView(
children: snapshot.data.docs.map((DocumentSnapshot documents) {
return DataTable(
rows: [
DataRow(cells: [
DataCell(documents['amount']),
DataCell(documents['date']),
DataCell(documents['category']),
DataCell(documents['reference']),
]),
],
);
}).toList(),
);
},
);
}
}
these are the exception caused by the widgets The following NoSuchMethodError was thrown building StreamBuilder(dirty, state: _StreamBuilderBaseState<QuerySnapshot, AsyncSnapshot>#7a426): The getter 'docs' was called on null. Receiver: null Tried calling: docs
The following _TypeError was thrown building StreamBuilder<QuerySnapshot>(dirty, state: _StreamBuilderBaseState<QuerySnapshot, AsyncSnapshot<QuerySnapshot>>#7a426):
type 'int' is not a subtype of type 'Widget'