In my flutter application i need to implement simple native Android screen
(for example handle back button pressed and create dialog - You are going to exit app (ok/cancel)
or
Button info about app )
How can i do this in my flutter project? it shouldn't be flutter code
You can achieve this by using Flutter's built-in function called WillPopScope and providing a dialog box with both options. Here's an example of the function.
Future<bool> onBackPressed() {
return showDialog(
context: context,
builder: (_) => DialogueBox(
title: 'EXIT',
message: 'Do you really want to exit the App ?',
onOKPress: () {
SystemChannels.platform.invokeMethod('SystemNavigator.pop');
},
),
);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.