【发布时间】:2020-06-02 19:48:07
【问题描述】:
我想退出我的申请。我已经实现了一个 WillPopScope,但看起来 onWillPop 函数根本没有被调用。我尝试了很多方法,例如将 WillPopScope 与 Scaffold 交换,更改函数的返回值,但它看起来不像预期的那样工作。
我的代码:
Future<bool> _willPopCallback() async { exit(0); // await showDialog or Show add banners or whatever // then return true; // return true if the route to be popped } return Scaffold( appBar: MyAppBar( leading: DrawerAction(), title: Text(AppLocalizations.of(context).textCapitalized('home_page')), onSearch: (searchTerms) => this.search(searchTerms, context), ), body: new WillPopScope( onWillPop: _willPopCallback, // Empty Function. child: //my screen widgets
我不确定这是我应该向 Flutter 报告的错误还是我做错了什么。很高兴根据要求提供更多代码。
我试过了:
exit(0);
Navigator.of(context).pop();
SystemChannels.platform.invokeMethod('SystemNavigator.pop');
提前致谢!
【问题讨论】: