I am getting this warning. I have read the documentation. But my code is returning the true, or false value on some condition. How can I migrate this?
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()
2
Answers
I have created a new variable
and then assigned this to canPop. This value is updated in the if condition.
You can replace that like this: