Repository navigation
systemNavigationBarIconBrightness: Brightness.dark resets to light onResume. #21265
Description
Activity
- changed the title
[-]systemNavigationBarIconBrightness: Brightness.dark resets to light onResum.[/-][+]systemNavigationBarIconBrightness: Brightness.dark resets to light onResume.[/+]on Aug 31, 2018 Please add the output of
flutter doctor -v.Looks like a part is missing from the fix to #4630
- addedframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packages
on Aug 31, 2018 @zoechi Here is my output of
flutter doctor -vflutter doctor -v
[✓] Flutter (Channel master, v0.7.4-pre.21, on Mac OS X 10.13.6 17G65, locale sv-SE) • Flutter version 0.7.4-pre.21 at /Users/arnas/development/tools/flutter • Framework revision 7cebaac985 (28 hours ago), 2018-08-29 21:53:39 -0700 • Engine revision 252da48082 • Dart version 2.1.0-dev.3.0.flutter-760a9690c2 [✓] Android toolchain - develop for Android devices (Android SDK 27.0.3) • Android SDK at /Users/arnas/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-P, build-tools 27.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01) • All Android licenses accepted. [✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 9.4.1, Build version 9F2000 • ios-deploy 1.9.2 • CocoaPods version 1.5.3 [✓] Android Studio (version 3.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 27.1.1 • Dart plugin version 173.4700 • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01) [✓] VS Code (version 1.26.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 2.17.1 [✓] Connected devices (1 available) • Nexus 5X • 013c535795c613eb • android-arm64 • Android 8.1.0 (API 27) • No issues found!Reacted by Günter Zöchbauer- addedplatform-androidAndroid applications specificallyAndroid applications specifically
on Aug 31, 2018 This constantly happens to me too, everytime the app is re-opened (not the initial open) - has there been a fix for this?
Only resets the systemNavigationBarIconBrightness, everything else stays as expected.
Listening
AppLifecycleState.resumedwithSystemChannels.lifecycle.setMessageHandlerdidn't work for me.It seems
AnnotatedRegioncan help:import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return AnnotatedRegion<SystemUiOverlayStyle>( value: SystemUiOverlayStyle( systemNavigationBarColor: Colors.white, systemNavigationBarIconBrightness: Brightness.dark, ), child: MaterialApp( ... ), ); } }
Reacted by Carlos Eugenio Torres, Amine, Steve Gehrman, Xgamefactory, Nero Song, Alex Melnikov, Joseph García, Rory Coulson, Ian Spryn, postpasspost and 2 more@sgehrman why is AnnotatedRegion bad?
Thanks for AnnotatedRegion.
But if you use AppBar it will totally override systemUiStyle
app_bar.dart line 588final Brightness brightness = widget.brightness ?? appBarTheme.brightness ?? theme.primaryColorBrightness; final SystemUiOverlayStyle overlayStyle = brightness == Brightness.dark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark; return Semantics( container: true, child: AnnotatedRegion<SystemUiOverlayStyle>( value: overlayStyle,we have edited app_bar.dart by removing AnnotatedRegion not a clean solution but
Thanks for AnnotatedRegion.
But if you use AppBar it will totally override systemUiStyle
app_bar.dart line 588final Brightness brightness = widget.brightness ?? appBarTheme.brightness ?? theme.primaryColorBrightness; final SystemUiOverlayStyle overlayStyle = brightness == Brightness.dark ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark; return Semantics( container: true, child: AnnotatedRegion<SystemUiOverlayStyle>( value: overlayStyle,we have edited app_bar.dart by removing AnnotatedRegion not a clean solution but
Just override you AppBar ThemeData with copywith().
There is a brigthness parameter for appbar but We have custom statusbar and navigation bar coloring not just dark light .
- addeda: layoutSystemChrome and Framework's Layout IssuesSystemChrome and Framework's Layout Issues
on Mar 12, 2020 9 remaining items
- addedfound in release: 1.22Found to occur in 1.22Found to occur in 1.22found in release: 1.26Found to occur in 1.26Found to occur in 1.26
on Jan 27, 2021 Listening
AppLifecycleState.resumedwithSystemChannels.lifecycle.setMessageHandlerdidn't work for me.It seems
AnnotatedRegioncan help:import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return AnnotatedRegion<SystemUiOverlayStyle>( value: SystemUiOverlayStyle( systemNavigationBarColor: Colors.white, systemNavigationBarIconBrightness: Brightness.dark, ), child: MaterialApp( ... ), ); } }
it worked for me
AnnotatedRegion(value: SystemUiOverlayStyle.dark,child: xxx,); not work in Flutter 2.8.1 on Device run in MiUi
Flutter 2.8.1 • channel stable • https://mirrors.tuna.tsinghua.edu.cn/git/flutter-sdk.git
Framework • revision 77d935a (5 weeks ago) • 2021-12-16 08:37:33 -0800
Engine • revision 890a5fca2e
Tools • Dart 2.15.1But the same code work in Flutter 2.5.1 in MiUi
Flutter 2.5.1 • channel unknown • unknown source
Framework • revision ffb2ece (4 months ago) • 2021-09-17 15:26:33 -0400
Engine • revision b3af521a05
Tools • Dart 2.14.2Listening
AppLifecycleState.resumedwithSystemChannels.lifecycle.setMessageHandlerdidn't work for me.It seems
AnnotatedRegioncan help:import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return AnnotatedRegion<SystemUiOverlayStyle>( value: SystemUiOverlayStyle( systemNavigationBarColor: Colors.white, systemNavigationBarIconBrightness: Brightness.dark, ), child: MaterialApp( ... ), ); } }
This was really helpful, but in my case I was using statusBar related customization also.
statusBarColor: Colors.transparent, statusBarIconBrightness: Brightness.darkwhich didn't work with the
AnnotatedRegionso my solution was like that
@override Widget build(BuildContext context) { SystemUiOverlayStyle uiOverlayStyle = SystemUiOverlayStyle( systemNavigationBarColor: Colors.white, systemNavigationBarDividerColor: Colors.white, systemNavigationBarIconBrightness: Brightness.dark, statusBarColor: Colors.transparent, statusBarIconBrightness: Brightness.dark); SystemChrome.setSystemUIOverlayStyle(uiOverlayStyle); return AnnotatedRegion<SystemUiOverlayStyle>( value: uiOverlayStyle, child: MaterialApp( ... ), ); }I have tried the solutions described here, nothing has helped yet.
Relying on an
AnnotatedRegionis the right solution (SystemChrome.setSystemUIOverlayStyleis an imperative API that might have to be called again, for instance after resuming the app).FYI, an
AppBarautomatically inserts anAnnotatedRegionand since #104827 is merged,AppBar.systemOverlayStylecan be used to style both the status bar and the system navigation bar.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 3, 2023
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIssue closed with comment
systemNavigationBarIconBrightness:Brightness.darkresets tolightonResume.This bug still live from beta 0.5.1 now I testing master 0.7.4 and i have same problem.
This is my code:
I have fixed it with this code below, but i think it should work with default code which is above.