Makrand Ray
Makrand Ray

Reputation: 13

Fetching Data which is of String Type From Cloud FireStore

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'],
        );

enter image description here

enter image description here

Upvotes: 0

Views: 35

Answers (1)

Shirsh Shukla
Shirsh Shukla

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

Related Questions