Reputation: 11
I want to turn off / lock the screen of my device by the clicking the icon of my app in flutter.
Like some new Android devices have this functionality.
Anyone Please guide me.
I am at beginner level in flutter.
Upvotes: 1
Views: 2292
Reputation: 276
you can use this plugin device_policy_manager it helps to lock the device immediately as if the lock screen timeout has expired at the point of this call. just follow the installation steps in the readme and this how u can use it
/// Return `true` if the given administrator component is currently active (enabled) in the system.
final status = await DevicePolicyManager.isPermissionGranted();
/// request administrator permission
await DevicePolicyManager.requestPermession("Your app is requesting the Adminstration permission");
/// lock the phone
await DevicePolicyManager.lockNow();
Upvotes: 0
Reputation: 629
The feature you are asking for needs native implications. The question has already been answered in one of the forum. It can be a bit tricky to implement. Have a look at the form link below
Upvotes: 1