Skip to content

Conversation

@jesswrd
Copy link
Contributor

@jesswrd jesswrd commented Jan 28, 2025

On Android devices, the statusBar is now by default transparent starting android API 35 here (due to automatic opt-in to edge to edge mode here), which is making the statusBar icons difficult to see. We decided to make the change in Cupertino/Material layer as opposed to the embedder layer becasue we cannot make assumptions on the defaults when we don't know what kind of Widgets the Flutter dev will be using.

In MaterialApp, the statusBarIconBrightness is made to be dark because the system's brightness (dark mode or light mode) does not affect the brightness of the default app. This means when I turn on dark mode on my phone, the app does not use a dark theme—it uses the same light theme.

In CupertinoApp, the statusBarIconBrightness is made to be opposite of the system's brightness (dark mode or light mode) because the system does affect the brightness of the default app. The system and the default app have the same brightness. This means when I turn on dark mode on my phone, the app also uses a dark theme.

Fixes #160305

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. f: cupertino flutter/packages/flutter/cupertino repository labels Jan 28, 2025
@jesswrd jesswrd changed the title [WIP] Fix Status Bar Icon Brightness Fix Status Bar Icon Brightness Jan 30, 2025
@jesswrd jesswrd marked this pull request as ready for review January 30, 2025 23:26
@jesswrd jesswrd requested review from Piinks and reidbaker January 30, 2025 23:27
expect(pressed, isTrue);
});

testWidgets('The status bar icons are dark by default', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this test be "the status bar icons are the opposite brightness of the system?

(related to me not following how ThemeMode works in relation to brightness)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Material app, I don't use the brightness of the system at all to determine the brightness of the icon. This is because the default app's brightness (from flutter create or flutter create -e) does not change when the system is in dark mode or light mode.


final bool useDarkTheme =
mode == ThemeMode.dark ||
(mode == ThemeMode.system && platformBrightness == ui.Brightness.dark);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to square this code with the review description. I think the default ThemeMode is system. Which means that material should also have the ternary logic about brightness.

That said I trust your evaluation so where am I misunderstanding the code?

Copy link
Contributor Author

@jesswrd jesswrd Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Material, the system's brightness does not reflect the brightness of the Flutter default app. This means when I turn the phone to dark mode, my app does not use a dark theme—it stays the same. I realize this code block has logic for using the dark theme. It's not triggering when I set the system to dark mode.

If I add ternary logic (similar to my CupertinoApp changes), I see the same bug from the issue where you cannot see the status bar icons. This bug does not appear in CupertinoApp (with ternary logic).

Also, I updated my description above. Instead of default I just put "made to be." I meant to the user, it looks like the default.

Copy link
Contributor Author

@jesswrd jesswrd Jan 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also that added line is there by accident from a previous commit. Deleting that now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that the bug is that material does not respect the phones brightness by default and that it should. That is what the documentation I linked seems to imply.

@Piinks who on your team might know the history of brightness and its default relationship with system brightness?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am less familiar with ThemeMode, cc @QuncCccccc for material and @MitchellGoodwin for cupertino. They may have some thoughts.

@jesswrd jesswrd force-pushed the i160305-statusbar-light-bug branch from 36cd41b to 3541a70 Compare January 31, 2025 19:46

final bool useDarkTheme =
mode == ThemeMode.dark ||
(mode == ThemeMode.system && platformBrightness == ui.Brightness.dark);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am less familiar with ThemeMode, cc @QuncCccccc for material and @MitchellGoodwin for cupertino. They may have some thoughts.

@jesswrd jesswrd force-pushed the i160305-statusbar-light-bug branch from 6dcee54 to 6367516 Compare February 3, 2025 21:45
@QuncCccccc QuncCccccc self-requested a review February 4, 2025 02:02
Copy link
Contributor

@QuncCccccc QuncCccccc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM:)

Copy link
Contributor

@MitchellGoodwin MitchellGoodwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Looks like the analyzer is unhappy about the sample code in system_chrome.dart.

@QuncCccccc
Copy link
Contributor

To fix the analyzer complaint, we can add

// Examples can assume:
// late BuildContext context;
...

on top of the file (below imports).

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 11, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 12, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 16, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 17, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 20, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I strongly oppose this PR because the changes have completely broken existing configuration methods. For example, the following code no longer works as intended:
void main() { WidgetsFlutterBinding.ensureInitialized(); SystemChrome.setSystemUIOverlayStyle( SystemUiOverlayStyle( statusBarIconBrightness: WidgetsBinding.instance!.platformDispatcher.platformBrightness == Brightness.light ? Brightness.dark : Brightness.light, ), ); runApp(const MainApp()); }
This modification has caused regression in functionality that was previously working correctly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please direct comments towards the open issue around this behavior. Merged PRs are difficult to track discussion on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

Development

Successfully merging this pull request may close these issues.

[android 15] Status bar text not legible with edge to edge and light theme

6 participants