Zhu
Zhu

Reputation: 407

Flutter: Turn off screen when phone close to face

I'm doing calling feature in Flutter and I need to know whether user wants to listen with earpeace and turn off the screen, set audio output to earpeace. Is there a sensor to know if phone is close to face/ear to turn off the screen ?

Upvotes: 4

Views: 1907

Answers (2)

Youssef Lasheen
Youssef Lasheen

Reputation: 26

The only package that worked and actually turned off the screen on proximity is the flutter_incall package like this:

IncallManager().turnScreenOff();
IncallManager().turnScreenOn();

The problem is that this package is so old and missing so many modern flutter updates like null-safety and Android embedding 2.0.

I tried using wakelock as many suggested, but the functionality is different from what I am looking for.

Upvotes: 0

Zhu
Zhu

Reputation: 407

I was able to know with this plugin proximity_sensor

Upvotes: 2

Related Questions