我收到此警告。我已阅读文档。但我的代码在某些条件下返回 true 或 false 值。我该如何迁移这个?
WillPopScope(
onWillPop: () async {
if (_actionIcon.icon == Icons.search) {
return true;
} else {
setState(() {
_actionIcon = const Icon(
Icons.search,
color: Colors.white,
);
_appBarTitle = Text('Heading',
_managePayrollBloc.add(_getSearch(""));
});
return false;
}
},
child: SomeChild()
你可以像这样替换它:
PopScope(
canPop: _myPopDisableEnableLogic(), // set it true according your app logic
onPopInvoked: (bool didPop) async {
// put if/ else condition part of your code here
},
)