Helo, I am trying to check if user's account exists, if no, I want to run text 'account is deleted'.
But the problem is that when I start the app there is screen for existing account and only after reset I can get the real result.
Looks like check for account is done after running app for the first time, but I don't know where is the mistake.
Here is the code, thank you in advance:
class CheckIfDeletedAccount extends StatelessWidget {
String isAccountDeleted;
getData() async {
var userType = await Firestore.instance
.collection('users')
.where('userEmail', isEqualTo: email)
.getDocuments();
userType.documents.forEach((result) {
log(result.data["deleted"]);
isAccountDeleted = result.data["deleted"].toString();
});
}
@override
Widget build(BuildContext context) {
getData();
//log(isAccountDeleted);
if (isAccountDeleted == "true") {
return Scaffold(
body: Container(
child: Center(
child: Text("account is deleted"),
),
),
);
}
return MaterialApp(
theme: themeData,
home: Scaffold(
body: Bar(),
),
);
}
}