Home > database >  The method '[]' can't be unconditionally invoked because the receiver can be 'nu
The method '[]' can't be unconditionally invoked because the receiver can be 'nu

Time:10-28

I have this problem in my snapshot

The method '[]' can't be unconditionally invoked because the receiver can be 'null'. Try making the call conditional (using '?.') or adding a null check to the target ('!').

enter image description here

enter image description here

Greetings I hope you are very well, someone could help me, it is my first time creating a mobile app and with firebare.

I tried by Var, put ! and nothing, I am not very aware of the error.

CodePudding user response:

try this

var horario = snapshot.value == null ? "" : snapshot.value!['nombre']; 

CodePudding user response:

I changed the version of the dependencies and the problem was solved.

before firebase_core: ^2.1.1 cloud_firestore: ^4.0.3 firebase_database: ^10.0.2

after firebase_core: ^1.4.0 cloud_firestore: ^3.1.5 firebase_database: ^6.0.0

  • Related