Hi I am building a app where user will add certain items and these items will be shown in a gridview. But when they register, at that stage they are yet to add anything in the database so firestore return nulls.
This is a new user so there is no data for the current user in firestore
I am checking for null value using:
builder: (BuildContext context, AsyncSnapshot<DocumentSnapshot> snapshot) {
if (!snapshot.hasData || !snapshot.data!.exists) {}
But still i am getting following error because it is not handling this scenario:
The following NoSuchMethodError was thrown building
StreamBuilder<DocumentSnapshot<Object?>>(dirty,
state: _StreamBuilderBaseState<DocumentSnapshot<Object?>,
AsyncSnapshot<DocumentSnapshot<Object?>>>#3898f):
The method '/' was called on null.
Receiver: null
Tried calling: /(60)
The relevant error-causing widget was:
StreamBuilder<DocumentSnapshot<Object?>>