Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
504 views
in Technique[技术] by (71.8m points)

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.

Example:

A -> B -> C -> D -> Force Logout -> Open Login Screen and close all previous screen.
question from:https://stackoverflow.com/questions/65931775/flutter-finish-all-the-screen-activity-for-android-ios-both

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

you can use this:

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

or if you have named routes:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...