我想退出我的应用程序.我已经实现了一个WillPopScope,但是看起来onWillPop函数根本没有被调用.我try 了很多方法,比如将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
我不确定这是一个错误,我应该向Ffltter报告,还是我做错了什么.很高兴根据要求提供更多代码.
我试过:
exit(0);
Navigator.of(context).pop();
SystemChannels.platform.invokeMethod('SystemNavigator.pop');
提前谢谢!