How Can I prevent user from using the app when the location service is off

I want to prevent the user from using the app when he turns of the location or if he doesnt give permission to the app to get the location.
I need to popup a dialog or a screen, that would inform the user that he needs to turn on the location to contiune using the app. The “Turn on your location” screen or dialog, should popup whenever the location service is off, and at any part of the app (except when the user is trying to register or login).

2 Likes

Consider using this plugin. It provides a clean approaches to handle OS level resources when they are enabled and disabled, with callbacks and future.

https://pub.dev/packages/permission_handler

I have used the same for camera.
If access to camera is denied, I bring up a dialog box with relevant message asking the user to allow access.

2 Likes

This is a great resource. Thanks for sharing! @maheshkrishnappa

1 Like