How to handle back button on appBar of Scaffold layout in flutter module and navigate to previous page on the host app

107 views Asked by At

I have a question, I have to create a flutter module and integrate it directly into the host app. I want to handle the back button on flutter UI by clicking it and navigating to the previous page on the host app. I use go_router to handle navigation on the module and host app. I have never integrated it. I have no idea to handle the back button it works on the appBar inside the flutter module. In this case, I would like to handle it by method channel or not?

I want to get the solution for the handle back button on the appBar in the flutter module. It must to click and navigate from flutter module and goto previous page on the host app.

1

There are 1 answers

0
Suttipong Kullawattana On

I just found a way. After setup the flutter module inside Android or iOS, We can use this code setup inside the AppBar to close the page.

            if(Platform.isAndroid){
              SystemNavigator.pop();
            } else {
              exit(0);
            }