Search code examples
androidflutterfirebasefirebase-realtime-databaseflutter-dependencies

Flutter Firebase snapshot code not working


I am using firebase real time database in my project. Normally, this structure works, but when I try, the function does not continue. I would be glad if you can help me what is the reason for this.

while(flag){
  print("i = ${i}");
  final snapshot2 = await ref.child('aaaaaaaaaaaaaaaaaaa/place/${i.toString()}').get();
 print(snapshot2.value);
  if(snapshot2.exists){
    print("Exits");
    i++;
  }else{
    print("Does not Exits");
    flag = false;
  }
}

Solution

  • better to recheck collection name in firestore. If the collection name not given properly that returns nothing.