0

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

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.

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 27 '22 at 08:24
  • Does this answer your question? [The method '\[\]' can't be unconditionally invoked because the receiver can be 'null'](https://stackoverflow.com/questions/67575893/the-method-cant-be-unconditionally-invoked-because-the-receiver-can-be-nu) – Dmytro Rostopira Oct 27 '22 at 10:48
  • Try to include code as Plain text in the code. This will Helps SEO. – Lal Krishna Oct 28 '22 at 17:54
  • What did you get on console when `print(snapshot.value);` runs ? – Lal Krishna Oct 28 '22 at 18:04

2 Answers2

0

try this

var horario = snapshot.value == null ? "" : snapshot.value!['nombre']; 
Fugipe
  • 386
  • 1
  • 8
0

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