Flutter 颤振-未来处理

Flutter 颤振-未来处理,flutter,asynchronous,async-await,Flutter,Asynchronous,Async Await,我有两个函数,其思想是1需要首先执行 Future<bool> _getProducts() async { father.Reload().then((value){//it will do a http request and refresh in the other screen, this other screen will bring data to the actual screen later if(value != null && va

我有两个函数,其思想是1需要首先执行

Future<bool> _getProducts() async {
   father.Reload().then((value){//it will do a http request and refresh in the other screen, this other screen will bring data to the actual screen later
     if(value != null && value is bool && value){
       print("1 finished");
       return Future.value(true);
     }
     return Future.value(true);
   });
   return Future.value(false);
 }

 Future Reload() async {
    await _getProducts().then((){
      print("2 finished");
    });
 } 
Future\u getProducts()异步{
然后((值){//它将执行http请求并在另一个屏幕中刷新,该另一个屏幕稍后将把数据带到实际屏幕
如果(value!=null&&value为bool&&value){
打印(“1件完成”);
返回未来值(true);
}
返回未来值(true);
});
返回Future.value(false);
}
Future Reload()异步{
等待_getProducts()。然后(){
打印(“2件完成”);
});
} 

我不明白为什么,但它总是在1完成之前打印2完成,我已经尝试了whencomplete、without await和其他可能性,但我仍然不明白

您需要使用
await
before
father.Reload()
这很有效,非常感谢