I have this FutureBuilder with the future beeing a request for a boolena value from firestore. But when I update the value (hasAccountSetup becames true), nothnig happens until I do a quick reload of the app.
I don't know if I should't be using FutureBuilder in this case, but the goal is for the app to return the HomePage() as soon as I update the hasAccountSetup to true in my firebase db.
Future<bool> _getCurrentUserData() async {
final DocumentSnapshot userDoc = await FirebaseFirestore.instance
.collection('Users')
.doc(Auth().currentUser!.uid)
.get();
return userDoc.get('HasSetupAccount');
}
class _WidgetTreeState extends State<WidgetTree> {
@override
//construtor da class?
Widget build(BuildContext context) {
return StreamBuilder(
stream: Auth().authStateChanges,
builder: (context, snapshot) {
if (snapshot.hasData) {
return FutureBuilder(
future: _getCurrentUserData(),
builder: ((context, AsyncSnapshot<bool> hasAccountSetup) {
if (hasAccountSetup.data == true) {
return MyHomePage();
} else {
return AccountSetup();
}
}));
} else {
return LoginPage();
}
},
);
}