Flutter how to use Future return value as if variable

后端 未结 5 990
离开以前
离开以前 2021-02-18 23:50

I want to get Future return value and use it like variable. I have this Future function

  Future _fetchUserInfo(String id)          


        
5条回答
  •  太阳男子
    2021-02-19 00:49

    use like this

    var username;
    dbHelper.getUsers().then((user) {
      username = user.getName;
    });
    

    this function returns future value

    dbHelper.getUsers()
    

    it is written like this

    getUsers() async { .... }
    

提交回复
热议问题