Deprecate ThemeData accentColor, accentColorBright, accentIconTheme, accentTextTheme #81336
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: