Reputation: 13
I want to retrieve the time which is of string type from firestore but when i do so i get an error saying .
The method '[]' was called on null. Receiver: null
: this(
id: id,
name: data['name'],
online: data['online'] && data['state'] != null,
isOn: (data['state'] != null) ? data['state']['on'] : false,
time: data['state']['Time'],
);
Upvotes: 0
Views: 35
Reputation: 5973
if your 'on'(inside of state) get proper. then you need get 'Time' as same with this condition,
this(
id: id,
name: data['name'],
online: data['online'] && data['state'] != null,
isOn: (data['state'] != null) ? data['state']['on'] : false,
time: (data['state'] != null) ? data['state']['Time'] : 'blank or null time text',
);
Upvotes: 1