Reputation: 23
I created new page in my app but i want to call function without set state
this is my function:
yaziGetir(Mahalle mahalle) {
FirebaseFirestore.instance
.collection("Mahalleler")
.doc(mahalle.neighborhood)
.get()
.then((gelenVeri) {
setState(() {
gelenYaziBasligi = gelenVeri.data()['Eğitim'];
gelenYaziIcerigi = gelenVeri.data()['Geri Dönüşüm'];
});
});
}
Upvotes: 2
Views: 8149
Reputation: 2272
You should make the call of your function in initState rather then in widget tree as everytime the widget is rebuild, it will call the function to execute again and again(leading to more reads).
@override
void initState()
{
super.initState();
yourFunction();//call it over here
}
Upvotes: 5