I have a Async method that I want to call in a stateless widget. While running it it says
Future dynamic Is not a sub type of widget
And then it shows the result after some seconds.How can I stop it? This is my method
var onvalue = await Firestore.instance
.collection("userdata")
.document(user.uid)
.get();
if (onvalue.exists) {
return Navigator.pushReplacement(context,
MaterialPageRoute(builder: (context) => mainhomepage()),);
}
else {
print("register");
return Navigator.pushReplacement(context,
MaterialPageRoute(builder: (context) => Register()),);
}
}
And my main body
Widget build(BuildContext context) {
var user = Provider.of<User>(context);
//return either home or authenticate
return MaterialApp (
home: user != null?check(user)//Calling the function
:app()
);
}