wkghd1223 / smusmu_application

smusmu application
0 stars 0 forks source link

unable to save realtime database result #5

Open nagarjunvv opened 4 years ago

nagarjunvv commented 4 years ago

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 }

wkghd1223 commented 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...

wkghd1223 commented 4 years ago

I really sorry about not to be able to help you

nagarjunvv commented 4 years ago

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.

wkghd1223 commented 4 years ago

i have no idea... i hope that this article is going to be helpful to you. this

nagarjunvv commented 4 years ago

As of now I am using global variable to save the data. But soon I need to change it.