I\'m a looking for a way to load async data on InitState method, I need some data before build method runs. I\'m using a GoogleAuth code, and I need to execute build method
Sample code:
@override
void initState() {
super.initState();
asyncOperation().then((val) {
setState(() {});
print("success");
}).catchError((error, stackTrace) {
print("outer: $error");
});
//or
asyncOperation().whenComplete(() {
setState(() {});
print("success");
}).catchError((error, stackTrace) {
print("outer: $error");
});
}
Future asyncOperation() async {
await ... ;
}