-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Support detection of light and dark system colors #164933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
chunhtai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you talk a bit more about the changes about this pr? It looks like this pr attempt to detect color palette for both light and dart modes? I thought the browser should be able to know whether the system setting is right? In that case, shouldn't we only need to provide the color palette that matches the current browser setting?
| final class SystemColorPalette { | ||
| SystemColorPalette._(this.brightness); | ||
|
|
||
| /// A palette of system colors for light mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will the value for light or dark change based on the light/dark setting of the browser?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. The user can get both light and dark system colors, regardless of system brightness settings.
Sure! Let me explain the steps that got me here:
|
chunhtai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
autosubmit label was removed for flutter/flutter/164933, because - The status or check suite Linux analyze has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/164933, because - The status or check suite Linux analyze has failed. Please fix the issues identified (or deflake) before re-applying this label. |
This PR introduces a `bool useSystemColors` parameter to the `ThemeData` constructor. The goal from this PR is to enable users to easily create high contrast themes that are based on system colors for their `MaterialApp`: ```dart MaterialApp( theme: ThemeData.light(), darkTheme: ThemeData.dark(), highContrastTheme: ThemeData(useSystemColors: true, ...), highContrastDarkTheme: ThemeData(useSystemColors: true, ...), ) ``` The `MaterialApp` widget will automatically pick the correct one of the 4 themes based on system settings (light/dark mode, high contrast enabled/disabled). Depends on #164933 Closes #118853
) This PR introduces a `bool useSystemColors` parameter to the `ThemeData` constructor. The goal from this PR is to enable users to easily create high contrast themes that are based on system colors for their `MaterialApp`: ```dart MaterialApp( theme: ThemeData.light(), darkTheme: ThemeData.dark(), highContrastTheme: ThemeData(useSystemColors: true, ...), highContrastDarkTheme: ThemeData(useSystemColors: true, ...), ) ``` The `MaterialApp` widget will automatically pick the correct one of the 4 themes based on system settings (light/dark mode, high contrast enabled/disabled). Depends on flutter#164933 Closes flutter#118853
Part of flutter#118853 This PR is an enhancement to flutter#163335 to provide detection of system colors for both light and dark mode. This is needed for the construction of a [`highContrastTheme`](https://api.flutter.dev/flutter/material/MaterialApp/highContrastTheme.html) and [`highContrastDarkTheme`](https://api.flutter.dev/flutter/material/MaterialApp/highContrastDarkTheme.html).
) This PR introduces a `bool useSystemColors` parameter to the `ThemeData` constructor. The goal from this PR is to enable users to easily create high contrast themes that are based on system colors for their `MaterialApp`: ```dart MaterialApp( theme: ThemeData.light(), darkTheme: ThemeData.dark(), highContrastTheme: ThemeData(useSystemColors: true, ...), highContrastDarkTheme: ThemeData(useSystemColors: true, ...), ) ``` The `MaterialApp` widget will automatically pick the correct one of the 4 themes based on system settings (light/dark mode, high contrast enabled/disabled). Depends on flutter#164933 Closes flutter#118853
Part of #118853
This PR is an enhancement to #163335 to provide detection of system colors for both light and dark mode. This is needed for the construction of a
highContrastThemeandhighContrastDarkTheme.