gpt4 book ai didi

flutter - Flutter此函数的返回类型为 'Future',但不以return语句结尾

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

我正在使用此方法,并且收到此消息。我该如何纠正?

This function has a return type of 'Future', but doesn't end with a return statement. Try adding a return statement, or changing the return type to 'void'.


Future<bool> _onWillPop() {
Navigator.of(context).pop(false);
Navigator.pushNamed(context, '/home');}

return WillPopScope(
onWillPop: _onWillPop,
child: Scaffold

谢谢!

最佳答案

您必须从returnbool _onWillPop()

Future<bool> _onWillPop() { 

Navigator.of(context).pop(false);
Navigator.pushNamed(context, '/home');
return true;// or false as per your need

}

关于flutter - Flutter此函数的返回类型为 'Future<bool>',但不以return语句结尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60525309/

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