Skip to content

Instantly share code, notes, and snippets.

@fredgrott
Created April 15, 2021 16:48
Show Gist options
  • Save fredgrott/a0674dc2d96e9af9f190e567390d61fd to your computer and use it in GitHub Desktop.
Save fredgrott/a0674dc2d96e9af9f190e567390d61fd to your computer and use it in GitHub Desktop.
full screen work-arounds for android using flutter native kotlin
import android.os.Build
import android.view.WindowManager
import androidx.core.view.WindowCompat
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
override fun onPostResume() {
super.onPostResume()
// to handle case of the bottom sys navbar
if(Build.VERSION.SDK_INT>= Build.VERSION_CODES.O_MR1){
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION)
}
// fixes edge to edge on 30 and beyond only
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
WindowCompat.setDecorFitsSystemWindows(window, false)
window.navigationBarColor = 0
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment