My solution to Flutter-Notch problem #117292
Labels
in triage
Presently being triaged by the triage team
waiting for customer response
The Flutter team cannot make further progress on this issue until the original reporter responds
Problem with fullscreen app on Android phones with notch
The essence of the problem
I must say right away I'm not a pro in flutter and android development.
There is a problem on Android 9 and 10 devices with notch in full screen mode.
First you need to set the cutout mode by setting a style in your activity.
Edit style.xml file like this:
To enable fullscreen mode we need to hide status bar and navigation bar. So at the start of the app add the following line...
And that's our problem. The display cutout overflows our app bar.
![](https://github.com/goliksim/Flutter/blob/main/DisplayCutout/img/1screen.jpg?raw=true)
SafeArea does not help in this situation in any way.
So, the most obvious solution to the problem is to add an insert on top yourself. But it is necessary to somehow determine the presence of the notch and its height.
In the MainActivity file.kt there is a method for determining the height of the notch using kotlin
But I haven't found a way to transfer the value to dart.
My solution
So my solution is to determine this inset just in dart. I found only one way to do that.
We can mesure it by systemGestureInsets which returns an area, where your tap belongs to status bar and not to our app.
Here is the discription from Google:
"Simple swipe gestures that start within the systemGestureInsets areas are used by the system for page navigation and may not be delivered to the app"
But there is an another problem. Standart android hight of status bar is 24dp. So, if we use this value, then we will have an insert on the device without a notch. To solve this, we can only use values that exceed the standard Android value.
I am using 48 as standart, because, according to my practice, devices with notch usually return exactly this value.
We can also measure the insert for the bottom just in case for devices with both notches.
Finally add this insert as padding before scaffold.
Result
Conclusion
I am not sure that this method is absolutely correct.
I'm also not sure if it works correctly on all devices because it doesn't have an Android 9.10 device with notch.
So, correct me in the comments, offer your thoughts. If this method is not suitable for your device, let me know.
You can find files in my repository
The text was updated successfully, but these errors were encountered: