Skip to content

Commit 78d3ea4

Browse files
authored
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]. <!-- Links --> [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
1 parent cdd2a42 commit 78d3ea4

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
package com.example.material_3_demo
22

33
import io.flutter.embedding.android.FlutterActivity
4+
import android.os.Bundle
5+
import androidx.core.view.WindowCompat
46

57
class MainActivity: FlutterActivity() {
8+
9+
override fun onCreate(savedInstanceState: Bundle?) {
10+
super.onCreate(savedInstanceState)
11+
WindowCompat.setDecorFitsSystemWindows(window, false)
12+
}
13+
614
}

material_3_demo/android/app/src/main/res/values/styles.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,19 @@
1414
This Theme is only used starting with V2 of Flutter's Android embedding. -->
1515
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
1616
<item name="android:windowBackground">?android:colorBackground</item>
17+
<!-- values-v29/themes.xml -->
18+
<item name="android:navigationBarColor">
19+
@android:color/transparent
20+
</item>
21+
22+
<!-- Optional: set to transparent if your app is drawing behind the status bar. -->
23+
<item name="android:statusBarColor">
24+
@android:color/transparent
25+
</item>
26+
27+
<!-- Optional: set for a light status bar with dark content. -->
28+
<item name="android:windowLightStatusBar">
29+
true
30+
</item>
1731
</style>
1832
</resources>

0 commit comments

Comments
 (0)