Muneeb Ajmal
Muneeb Ajmal

Reputation: 11

How to screen off or lock the device by clicking our app icon in flutter

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

Answers (3)

Iheb Briki
Iheb Briki

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

saytoonz
saytoonz

Reputation: 325

There are couple of plugins out there you can check them

flutter_screen_lock

flutter_lock_screen

Upvotes: 1

Rafat Rashid Rahi
Rafat Rashid Rahi

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

stack overflow solution

Upvotes: 1

Related Questions