I have recently upgraded my flutter to the latest version and I am getting all the null safety errors.
StreamBuilder(
stream: FirebaseFirestore.instance
.collection('restaurants')
.doc(partnerId)
.snapshots(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: CircularProgressIndicator(),
);
}
final restaurant = snapshot.data;
startTime = restaurant['startTime'].toDate();
endTime = restaurant['endTime'].toDate();
I am getting the following error when I assign restaurant[''] to any variable.
The method '[]' can't be unconditionally invoked because the receiver can be 'null'.
If I do this - restaurant!['endTime'].toDate();
, new error comes
The operator '[]' isn't defined for the type 'Object'. Try defining the operator '[]'.