While I was doing my project I encounter unforeseen condition where if I open a page where I have nested FutureBuilder widget then going back to another page and focusing on text field to type something resulted navigation to the same page where i have nested futurebuilder.
_UserProfileState() {
FromSharedPref().getString('userId').then((value) {
setState(() {
userId = value;
});
});
}
@override
Widget build(BuildContext context) {
return FutureBuilder<DocumentSnapshot>(
future: FirebaseFirestore.instance.collection('users').doc(userId).get(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Container(
color: Colors.white,
child: Center(
child: CircularProgressIndicator(),
),
);
} else {
AppUser user = AppUser.fromJason(snapshot.data.data());
return ProfileForm(
user: user,
);
}
},
);
}
}
When I tired to get the sharedPreference data using future builder then I encountered that error. But it was gone when I removed nested futureBuilder.