Open nagarjunvv opened 4 years ago
i don't know what exactly that is (actually I didin't learn about firebase store). but I guess that is Async / Sync problem...
I really sorry about not to be able to help you
For now temporarily I am using global variable but when I assign the same value to a normal variable , the value is reset to old value the moment it come out of the scope of firebase call.
i have no idea... i hope that this article is going to be helpful to you. this
As of now I am using global variable to save the data. But soon I need to change it.
I am trying to save a list variable it is working inside the close but not working outside the close.
I don't know if it is the limitation on firebase. But i need to save the variable outside of the closure.
Please help here is the code.I am using flutter in android studio.
Let me know if you need more info.
List getWidgets(context)
{
List wlist1;
List list = new List();
DatabaseReference dbRef = FirebaseDatabase.instance.reference().child("Winners");//.child("Level1");
dbRef.child("Level1").once().then((DataSnapshot snapshot) {
Map<dynamic, dynamic> values=snapshot.value;
wlist1 = (values["wlist"]);
print(values["wlist"]);//working
print(wlist1[1]);//working
});
print(wlist1[1]);//not working
}