Flutter : finish all the screen/activity (for android/iOS both)


How can I finish all the activity/screen in Flutter.

I want it for Android and iOS.

Is there any way to same like finishAffinity() in Android we do.


A -> B -> C -> D -> Force Logout -> Open Login Screen and close all previous screen.


you can use this:

Navigator.pushAndRemoveUntil(context, yourRouteToLogin, (route) => false);

or if you have named routes:

      context, yourRouteName, (Route<dynamic> route) => false);

Answered By – BosS

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *