Repository navigation
Using systemNavigationBarDividerColor changes statusBarIconBrightness and systemNavigationBarIconBrightness on Android11 #100027
Description
Activity
- addedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Mar 14, 2022 Reproducible on
stableandmaster.complete code sample
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() { runApp(const MyApp()); } final AppBarTheme appBarLight = AppBarTheme( backgroundColor: Colors.white.withAlpha(0xEE), foregroundColor: Colors.black, elevation: 0.5, systemOverlayStyle: SystemUiOverlayStyle.dark.copyWith( statusBarColor: Colors.transparent, ), ); class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Annotated Region Issue', theme: ThemeData.from(colorScheme: const ColorScheme.light()) .copyWith(appBarTheme: appBarLight), home: const MyHomePage(title: 'Annotated Region Issue'), ); } } class MyHomePage extends StatelessWidget { const MyHomePage({Key? key, required this.title}) : super(key: key); final String title; @override Widget build(BuildContext context) { final MediaQueryData media = MediaQuery.of(context); final double topPadding = media.padding.top + kToolbarHeight; final double bottomPadding = media.padding.bottom; SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); return AnnotatedRegion( value: SystemUiOverlayStyle( systemNavigationBarColor: Colors.white.withAlpha(0xBB), systemNavigationBarDividerColor: Colors.red.withAlpha(0x55), systemNavigationBarIconBrightness: Brightness.dark, systemNavigationBarContrastEnforced: false, ), child: Scaffold( extendBody: true, extendBodyBehindAppBar: true, appBar: AppBar( title: Text(title), ), body: GridView.builder( padding: EdgeInsets.fromLTRB(10, topPadding + 10, 10, bottomPadding + 10), gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3, mainAxisSpacing: 8, crossAxisSpacing: 8, childAspectRatio: 2, ), itemCount: 100, itemBuilder: (context, index) => Card( color: Colors.primaries[index % Colors.primaries.length][800]!, elevation: 2, child: Center( child: Text( 'Tile nr ${index + 1}', style: const TextStyle(color: Colors.white, fontSize: 16), ), ), ), ), ), ); } }
flutter doctor -v
[✓] Flutter (Channel stable, 2.10.3, on macOS 12.2.1 21D62 darwin-arm, locale en-GB) • Flutter version 2.10.3 at /Users/nexus/dev/sdks/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 7e9793dee1 (12 days ago), 2022-03-02 11:23:12 -0600 • Engine revision bd539267b4 • Dart version 2.16.1 • DevTools version 2.9.2 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/nexus/Library/Android/sdk • Platform android-32, build-tools 31.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763) [☠] IntelliJ IDEA Community Edition (the doctor check crashed) ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues. ✗ FormatException: Unexpected extension byte (at offset 5) • #0 _Utf8Decoder.convertSingle (dart:convert-patch/convert_patch.dart:1789:7) #1 Utf8Decoder.convert (dart:convert/utf.dart:351:42) #2 InputStream.readString (package:archive/src/util/input_stream.dart:207:30) #3 new ZipDirectory.read (package:archive/src/zip/zip_directory.dart:40:30) #4 ZipDecoder.decodeBuffer (package:archive/src/zip_decoder.dart:19:30) #5 ZipDecoder.decodeBytes (package:archive/src/zip_decoder.dart:14:12) #6 IntelliJPlugins._findPluginXml (package:flutter_tools/src/intellij/intellij.dart:130:44) #7 IntelliJPlugins._readPackageVersion (package:flutter_tools/src/intellij/intellij.dart:141:40) #8 IntelliJPlugins.validatePackage (package:flutter_tools/src/intellij/intellij.dart:63:35) #9 IntelliJValidator.validate (package:flutter_tools/src/intellij/intellij_validator.dart:103:15) #10 asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:111:32) #11 asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:109:18) #12 _rootRun (dart:async/zone.dart:1426:13) #13 _CustomZone.run (dart:async/zone.dart:1328:19) #14 _runZoned (dart:async/zone.dart:1861:10) #15 runZonedGuarded (dart:async/zone.dart:1849:12) #16 runZoned (dart:async/zone.dart:1780:12) #17 asyncGuard (package:flutter_tools/src/base/async_guard.dart:109:3) #18 Doctor.startValidatorTasks (package:flutter_tools/src/doctor.dart:205:9) #19 Doctor.diagnose (package:flutter_tools/src/doctor.dart:309:47) #20 DoctorCommand.runCommand (package:flutter_tools/src/commands/doctor.dart:50:48) #21 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1320:12) <asynchronous suspension> #22 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1161:27) <asynchronous suspension> #23 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension> #24 CommandRunner.runCommand (package:args/command_runner.dart:209:13) <asynchronous suspension> #25 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9) <asynchronous suspension> #26 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension> #27 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5) <asynchronous suspension> #28 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9) <asynchronous suspension> #29 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension> #30 main (package:flutter_tools/executable.dart:94:3) <asynchronous suspension> [✓] VS Code (version 1.65.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.36.0 [✓] Connected device (3 available) • sdk gphone arm64 (mobile) • emulator-5554 • android-arm64 • Android 11 (API 30) (emulator) • macOS (desktop) • macos • darwin-arm64 • macOS 12.2.1 21D62 darwin-arm • Chrome (web) • chrome • web-javascript • Google Chrome 99.0.4844.51 [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category.[✓] Flutter (Channel master, 2.11.0-0.0.pre.871, on macOS 12.2.1 21D62 darwin-arm, locale en-GB) • Flutter version 2.11.0-0.0.pre.871 at /Users/nexus/dev/sdks/flutters • Upstream repository https://github.com/flutter/flutter.git • Framework revision 4f4c7816c3 (4 hours ago), 2022-03-14 07:35:07 +0100 • Engine revision 6239bfb884 • Dart version 2.17.0 (build 2.17.0-182.0.dev) • DevTools version 2.11.1 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/nexus/Library/Android/sdk • Platform android-32, build-tools 31.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763) [✓] IntelliJ IDEA Community Edition (version 2021.3) • IntelliJ at /Applications/IntelliJ IDEA CE.app • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin version 213.5744.122 [✓] VS Code (version 1.65.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.36.0 [✓] Connected device (3 available) • sdk gphone arm64 (mobile) • emulator-5554 • android-arm64 • Android 11 (API 30) (emulator) • macOS (desktop) • macos • darwin-arm64 • macOS 12.2.1 21D62 darwin-arm • Chrome (web) • chrome • web-javascript • Google Chrome 99.0.4844.51 [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found!- addedplatform-androidAndroid applications specificallyAndroid applications specificallyframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.engineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.e: OS-version specificAffects only some versions of the relevant operating systemAffects only some versions of the relevant operating systemhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onfound in release: 2.10Found to occur in 2.10Found to occur in 2.10found in release: 2.11Found to occur in 2.11Found to occur in 2.11and removedin triagePresently being triaged by the triage teamPresently being triaged by the triage team
on Mar 14, 2022 cc @blasten
- addedP2Important issues not at the top of the work listImportant issues not at the top of the work list
on Mar 14, 2022 I thought this was a regression, but I don't see any changes that affected these code paths during this time window.
The commits reverted in flutter-team-archive/engine#32007 didn't make it to the stable version.@camsim99 could you investigate this further since you have been working with status bars recently?
Reacted by Rydmike6 remaining items
On the
systemNavigationBarDividerColorimpacting setting the icon brightness issue, it seems like there was a missing window flag that needed to be set for it to work. I'm still investigating thesystemNavigationBarDividerColorimpacting a transparent navigation bar issue, but I'll update here with a PR making the fixes when I do.Reacted by Rydmike and Kate LovettThanks @jonahwilliams & @camsim99.
From the reproduction, I can also see there are a combination of different system chrome styles being applied, one through the app bar and the other through the annotated region. For each issue listed, a minimal reproduction of code should make it easier to identify each root cause.
Reacted by RydmikeThis PR should fix the API 30 issue with setting system bar icon brightness on API 30.
In terms of the issue with having a translucent navigation bar and setting the divider color, this is due to the underlying Android API we need to use in order to style the system bars, so I will send out a PR to note this in the documentation as @rydmike suggested.
Reacted by RydmikeRegarding the system chrome style via the
AppBar. In an app you don't really have much choice than using bothSystemUiOverlayStylevia both the AppBar (as long as the app/page in question has anAppBarand anAnnotatedRegion, if you want to style both, because:- The
AppBaralways makes a defaultSystemUiOverlayStyle, it uses a default one if you did not specify one. - Defining a custom
systemOverlayStylefor theAppBarand in it specifying anySystemUiOverlayStyleproperties that concern the system navigation bar, by using any of itssystemNavigationBar*properties have no impact at all on the Android system navigation bar when used via theAppBar! - Thus if your screen/app has an
AppBarand you want to style both the AndroidAppBarand its system navigation bar, you have to do it using both theAppBarand an extraAnnotatedRegion.
I find it both a bit confusing and frustrating that if you have an
AppBarand are already styling its status bar with itssystemOverlayStyle, that you can't at the same time define the desired properties for the system navigation bar, via samesystemOverlayStyle. All the props forsystemNavigationBar*are there in the sameSystemUiOverlayStyle, they just don't do anything to the system navigation bar if you try to use them via theAppBar.One could argue that this makes sense, since we are defining things for an
AppBarthat does not really have anything to do with the system navigation bar. On the other hand the properties are there, if they have no impact, they should not exists at all in the usedAppBar"systemOverlayStyle" config class. Or at the least it is should be very clearly documented that they have no impact and that you have to set them via anAnnotatedRegion. But why not let them work also via theAppBar?Imo it would be very convenient in many cases if setting them also worked via the
AppBar. Since theAppBaris usually closer in the Widget tree than anAnnotatedRegion, its settings would have precedence also for the system navigation bar, if both are specified.The
AnnotatedRegionis of course needed for styling both status bar and system navigation bar in screens/apps that do not have anAppBar.Reacted by Zane Zhang- The
Un-assigning myself as I'm not actively working on this.
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle( systemNavigationBarColor: Color(0x0A000000), ))
I re-tested this with Android versions from 9 to 13. I could no longer reproduce any of the actual issues reported above on Android 9 and 11 in Flutter stable 3.7.7, so I'm closing this issue as fixed and completed.
There are other aspect about the AnnotatedRegion and SystemUiOverlayStyle that may still benefit from improvements in usability in documentation, but other issue have or are capturing that.
Reacted by Daniel Agbemava and Bruno Leroux- added a commit that references this issue
on Mar 15, 2023 - addedr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
on Mar 15, 2023 This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Mar 29, 2023


Steps to Reproduce
When you use an
AnnotatedRegionto control the design of the system navigation bar on Android thestatusBarIconBrightnessandsystemNavigationBarIconBrightnessunexpectedly change toBrightness.lightif you give any value tosystemNavigationBarDividerColoron Android 11 (SDK30).To see the issue try the provided code sample with different Android SDK API versions.
Reproduction sample code
Actual results
Results from Pixel4XL at shown Android SDK API level using the 3 button system navigation style to make the results more visible. The results are the same with the smaller swipe navigation too, but not as visible.
Expected results
Expected that the system navigation bar icons and status bar icons would have remained dark on Android 11 (SDK 30) as in result from Android 10 (SDK 29) and Android 12 (SDK 31). Surprisingly even the status bar icons change their brightness, even though they are not set in the
SystemUiOverlayStyleused in theAnnotatedRegionat all.Expected that Android 9 (SDK 28) would have gotten a white system navigation bar with opacity. This was expected since the documentation states:
Since Android O, is Android Oreo, version 8.0 (SDK 26), then setting the
systemNavigationBarColorshould have worked also in this case with Android 9 (SDK 28), but as shown it did not change color.Tested Flutter versions
The issue exists in latest Flutter stable 2.10.3 and master channel version shown below:
Flutter doctor from master
System navigation bar divider is a surface layer, not a divider line
If you on Android 10, 11 and 12 set
systemNavigationBarDividerColorto a color with opacity, then the system navigation bar becomes almost opaque and no longer has the opacity defined bysystemNavigationBarColor. As shown here:It seems like the
systemNavigationBarDividerColoris a full layer behind the navigation bar with just a 1dp higher height. We can test this theory with separate colors on divider and the system navigation bar, with both having suitable opacity:Which reveals that this is in fact the case. Here we can see a translucent white surface on the navigation bar, showing the translucent red divider surface behind it, with it reaching about 1dp higher and top part being visible as a red semi transparent line.
To not have any impact from the
systemNavigationBarDividerColoron thesystemNavigationBarColorwith opacity, you have to use fully transparent colorColors.transparenton the divider color.Knowing that the divider color is in fact the color of a full surface behind the system navigation bar that is just 1dp higher than navigation bar area, and not a divider line, is a critical piece of information when dealing with how to use it when using opacity on the system navigation bar background. You can use this knowledge to create a system navigation bar area that has some transparency and a divider, but the transparency will be a sum of both colors and their transparency.
Consider documenting this critical information about the system navigation bar divider.
SystemUiOverlayStyle Documentation
Consider using clearer documentation of what feature is supported on which versions for each property in
SystemUiOverlayStyle.Prefer always stating Android version and SDK API level. Avoid using internal code version letters like "O" and "P", instead prefer saying "Android 8 (SDK 26)" and "Android 10 (SDK 29)".
Avoid using terms like SDK 29+, it is unclear if this means 29 and higher or higher than 29. Fortunately the docs do mention the unambiguous version too, but in some cases with the confusing Android one letter version code. Why include the ambiguous version at all?
Examples:
Related issues
At least these issues touch subjects related to this issue, but are slightly different.