I make initPlatformState .. an async function to detect mock location and after the process of initPlatformState function is finished I need to do something...but the problem is... because initPlatformState is working asynchronously and I am not putting initPlatformState inside initState... initPlatformState will work before it is not done yet... is there a way to wait initPlatformState has done doing the process and then I will do something else?
here is my code
bool canMockLocation=false;
initPlatformState() async {
if (!mounted) return;
try {
canMockLocation = await TrustFall.canMockLocation;
} catch (error) {
print(error);
}
setState(() {
canMockLocation = canMockLocation;
});
}
_getData() async {
setState(() {
load = true;
});
initPlatformState();
setState(() {
load = false;
});
if(canMockLocation){
show alert;
}else{
print("check");
}
and here is for my widget
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
loadLocation
? Text("Loading...")
: Text("Success")
.....