How to add native android screen to flutter app?

266 views Asked by At

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

1

There are 1 answers

0
Usman Akhlaq On

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');
    },
  ),
);

}