Finish FlutterActivity from Flutter when integrating Flutter to native host app [Add2App] Finish FlutterActivity from Flutter when integrating Flutter to native host app [Add2App] flutter flutter

Finish FlutterActivity from Flutter when integrating Flutter to native host app [Add2App]


Solution found:

SystemChannels.platform.invokeMethod<void>('SystemNavigator.pop');

Removes the topmost Flutter instance, presenting what was before it.

On Android, removes this activity from the stack and returns to the previous activity.

Documentation here: api reference


...leading: BackButton(          onPressed: () => {            if (Navigator.canPop(context))              {Navigator.pop(context)}            else              {SystemNavigator.pop()}          },        )...