The following code throws this error "The method '[]' can't be unconditionally invoked because the receiver can be 'null'"
if (snapshot.hasData == true) {
return ListView(
children: snapshot.data!.docs.map((DocumentSnapshot document) {
return ListTile(
title: Text(document.data()['title']),
);
}).toList(),
);
}
Is it related to null-safety? how to fix it?