-
Notifications
You must be signed in to change notification settings - Fork 27.1k
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
Deprecate ThemeData accentColor, accentColorBright, accentIconTheme, accentTextTheme #81336
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Apr 28, 2021
d6d4ee3
to
7493641
Compare
This was referenced Apr 28, 2021
darrenaustin
approved these changes
Apr 29, 2021
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. Nice to see this go.
247dad0
to
26b2e85
Compare
22791c7
to
4ef0c33
Compare
Google testing passed upon deflake |
This was referenced Jun 23, 2021
40 tasks
smanilov
added a commit
to smanilov/t700kilos
that referenced
this pull request
Mar 20, 2024
Related to flutter PR81336: flutter/flutter#81336
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
f: material design
flutter/packages/flutter/material repository.
framework
flutter/packages/flutter repository. See also f: labels.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Deprecate the ThemeData accentColor, accentColorBrightness, accentIconTheme, and accentTextTheme properties because they are no longer used by the material library (see #56918).
The official migration guide is https://flutter.dev/docs/release/breaking-changes/theme-data-accent-properties
Summary
The ThemeData
accentColor
,accentColorBrightness
,accentIconTheme
andaccentTextTheme
properties have been deprecated.The Material Design spec no longer specifies or uses an "accent" color for the Material components. The default values for component colors are derived from the overall theme's color scheme. The
ColorScheme
'ssecondary
color is now typically used instead ofaccentColor
and theonSecondary
color is used when a contrasting color is needed.Context
This was a small part of the Material Theme System Updates project.
As of Flutter 1.17, the ThemeData accent properties - accentColor, accentColorBrightness, accentIconTheme, and accentTextTheme - were no longer used by the Material library. They had been replaced by dependencies on the theme's
colorScheme
andtextTheme
properties as part of the long-term goal of making the default configurations of thematerial components depend almost exclusively on these two properties.
The motivation for these changes is to make the theme system easier to understand and use. The default colors for all components are to be defined by the components themselves and based on the color scheme. The defaults for specific component types can be overridden with component-specific themes like
FloatingActionButtonTheme
orCheckBoxTheme
. Previously, properties like accentColor were used by a handful of component types and only in some situations, which made it difficult to understand the implications of overriding them.Description of change
The ThemeData accentColor, accentColorBrightness, accentIconTheme and accentTextTheme properties have been deprecated because the Material library no longer uses them.
Migration guide
Application theme
ThemeData
values no long need to specify accentColor, accentColorBrightness, accentIconTheme, or accentTextTheme.To configure the appearance of the material components in about the same way as before, specify the color scheme's secondary color instead of accentColor.
Code before migration:
Code after migration:
accentColor
The closest backwards compatible
ColorScheme
color isColorScheme.secondary
. To hew most closely to the latest Material Design guidelines one can substituteColorScheme.primary
instead. If a contrasting color is needed then useColorScheme.onSecondary
.Custom components that used to look up the theme's accentColor, can look up the
ColorScheme.secondary
instead.Code before migration:
Code after migration:
accentColorBrightness
The static
ThemeData.estimateBrightnessForColor()
method can be used to compute the brightness of any color.accentTextTheme
This was white TextStyles for dark themes, black TextStyles for light themes. In most cases
textTheme
can be used instead. A common idiom was to refer to one TextStyle from accentTextTheme, since the text style's color was guaranteed to contrast well with the accent color (nowColorScheme.secondaryColor
). To get the same result now, specify the text style's color asColorScheme.onSecondary
:Code before migration:
Code after migration:
accentIconTheme
This property had only been used to configure the color of icons within a
FloatingActionButton
. It's now possible to configure the icon color directly or with theFloatingActionButtonTheme
. See FloatingActionButton and ThemeData's accent properties.Timeline
Landed in version: 2.3.0-0.1.pre
In stable release: not yet
References
Relevant issues:
Relevant PRs:
Other: