From 78d3ea47c951f839b29e3e7d6f1e4df658564106 Mon Sep 17 00:00:00 2001 From: James Williams <66931+jwill@users.noreply.github.com> Date: Fri, 20 Sep 2024 14:34:12 -0400 Subject: [PATCH] m3_demo - Enables edge to edge support. (#2441) Edge to edge is coming by default to Flutter 3.26+ (or thereabouts) when the targetSdk is raised to Android 15(API 35). In the meantime, it can be done manually by adjusting the theme and setting `WindowCompat.setDecorFitsSystemWindows`. The fix is purely on the Android side. iOS is unaffected. Sourced from https://developer.android.com/develop/ui/views/layout/edge-to-edge-manually Fixes #1720 . ## Pre-launch Checklist - [X] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [X] I signed the [CLA]. - [X] I read the [Contributors Guide]. - [X] I updated/added relevant documentation (doc comments with `///`). - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-devrel channel on [Discord]. [Flutter Style Guide]: https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md [CLA]: https://cla.developers.google.com/ [Discord]: https://github.com/flutter/flutter/blob/master/docs/contributing/Chat.md [Contributors Guide]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md --- .../com/example/material_3_demo/MainActivity.kt | 8 ++++++++ .../android/app/src/main/res/values/styles.xml | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/material_3_demo/android/app/src/main/kotlin/com/example/material_3_demo/MainActivity.kt b/material_3_demo/android/app/src/main/kotlin/com/example/material_3_demo/MainActivity.kt index db3a75c76..738e2951e 100644 --- a/material_3_demo/android/app/src/main/kotlin/com/example/material_3_demo/MainActivity.kt +++ b/material_3_demo/android/app/src/main/kotlin/com/example/material_3_demo/MainActivity.kt @@ -1,6 +1,14 @@ package com.example.material_3_demo import io.flutter.embedding.android.FlutterActivity +import android.os.Bundle +import androidx.core.view.WindowCompat class MainActivity: FlutterActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + WindowCompat.setDecorFitsSystemWindows(window, false) + } + } diff --git a/material_3_demo/android/app/src/main/res/values/styles.xml b/material_3_demo/android/app/src/main/res/values/styles.xml index cb1ef8805..e0ae24bde 100644 --- a/material_3_demo/android/app/src/main/res/values/styles.xml +++ b/material_3_demo/android/app/src/main/res/values/styles.xml @@ -14,5 +14,19 @@ This Theme is only used starting with V2 of Flutter's Android embedding. -->