'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 ?
Solution 1:[1]
I was able to know with this plugin proximity_sensor
Solution 2:[2]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Zhu |
Solution 2 |