Is there a way to load async data on InitState method?

You can create an async method and call it inside your initState

@override
void initState () {
  super.initState();
  WidgetsBinding.instance.addPostFrameCallback((_){
    _asyncMethod();
  });
        
}

_asyncMethod() async {
  _googleSignIn.onCurrentUserChanged.listen((GoogleSignInAccount account)     {
    setState(() {
      _currentUser = account;
    });
  });
  _googleSignIn.signInSilently();
}

As of now using .then notation seems to work:

  // ...
  @override
  initState() {
    super.initState();
    myAsyncFunction
    // as suggested in the comment
    // .whenComplete() {
    // or
      .then((result) {
    print("result: $result");
    setState(() {});
    });
  }
  //...

Tags:

Dart

Flutter