gpt4 book ai didi

c# - Flutter中 'Future'的实例

转载 作者:行者123 更新时间:2023-12-03 03:10:17 29 4
gpt4 key购买 nike

我从服务器获取一个int Id,该服务器在HTTP请求中抖动,可以,并且我想将此值保存在变量中,但是当我调用返回的值时,我得到了这个错误“Future”的实例,有什么建议吗? ?
这是代码

                    child: RaisedButton(onPressed:() {
CurrentPrjId= SaveProject();
print("CurrentPrjId Is saved CurrentPrjId :::::::: " );
print(CurrentPrjId);
Navigator.of(context).pushReplacementNamed('/AllUSerStories');
}
//Save Project

Future SaveProject() async {

//SaveProjectResult has the id of the current created project which i need that for its user stories
var SaveProjectResult = await GetPostProjects().createProject(_ProjectnameController.text, _CustomernameController.text, _dropNewItem, _dropNewItem2, _StartDateController.text, _EndDateController.text,);
print(":::::::::::::::::::::::::::::::The Project Is Created And Here Its ID In SaveProject:::::::::");
print(SaveProjectResult);
return SaveProjectResult;

}

最佳答案

没有代码,很难猜测发生了什么。.但是您可以尝试等待将来的完成..这样做:

methOdThatLoadsId().then((id) => print("Id that was loaded: $id"));

要么
var id = await methodThatLoadsId();

祝好运 :)

关于c# - Flutter中 'Future<dynamic>'的实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55744894/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com