Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to work with WillPopScope or disable back press from android device. #324

Open
ngee147 opened this issue May 3, 2023 · 4 comments
Open

Comments

@ngee147
Copy link

ngee147 commented May 3, 2023

Is that anyway I can achieve to not allow user to do back press and close the App in Android device?

@rrickyzz
Copy link

theres no way

@xniko
Copy link

xniko commented Sep 15, 2023

If you want to use WillPopScope you would have to override the popRoute on RoutemasterDelegate with return pop(); like detailed in this issue #176 (comment)

@robrob-creator

This comment was marked as resolved.

@killik-dan-stubbs
Copy link

killik-dan-stubbs commented Jun 17, 2024

If you want more detail on how to resolve this, I suggest making your own custom class that extends RoutemasterDelegate then overriding the pop function. It should look like this:

class CustomRoutemasterDelegate extends RoutemasterDelegate {
  CustomRoutemasterDelegate({
    required GlobalKey<NavigatorState> super.navigatorKey,
    required List<RoutemasterObserver> super.observers,
    required super.routesBuilder,
  });

  @override
  Future<bool> popRoute() => pop();
}

Then, just replace your RoutemasterDelegate class name with CustomRoutemasterDelegate and you should be fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants