【发布时间】:2021-08-11 15:47:41
【问题描述】:
我已经对方法进行了更改,如下所示,调用它时我不知道如何修复它。这个问题是在我升级并尝试解决所有不可空或“空安全”后引起的
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: ()=> showDialog<bool>(context: context,
builder: (context)=> AlertDialog(
title: Text('Alert'),
content: Text('Voulez vous quitter l\'application ?'),
actions: [
TextButton(onPressed:(){
if (Platform.isAndroid) {
SystemNavigator.pop();
} else if (Platform.isIOS) {
exit(0);
}
},
child: Text('Oui')),
TextButton(onPressed: () => Navigator.of(context).pop(false),
child: Text('Non')
)
],
)
),
child: Scaffold()
}
这里是错误错误:返回类型“Future”不是“Future”,这是闭包上下文所要求的。
我该如何解决这个问题?
【问题讨论】:
-
尝试将
onWillPop: ()=>更改为onWillPop: () async => -
我做到了。没有任何改变
-
您的问题似乎与此stackoverflow.com/questions/67184531/…有关