Reputation: 2012
When press back button on android, the app will be killed. I want my whole app have the feature that when back button pressed, users will get a notice to ask for confirmation. If they confirm then minimize the app. So I tried to wrap the whole 'MaterialApp' as a child inside 'WillPopScope'. However the 'onWillPop' is not triggered.
void main() async {
runApp(
WillPopScope(
child: MaterialApp(
title: 'Test',
home: Frame(),
),
onWillPop: () async {
print('will pop!!!!!!!!!');
return false;
},
),
);
}
Upvotes: 1
Views: 1326
Reputation: 909
You should not surround your entire app with this. You should be using this per page widget that you want the functionality to run on. Surround your Scaffold for your page
Upvotes: 3