Step 2 of 2: Remove Flutter's FloatingActionButton dependency on ThemeData accent properties #46923
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.
Remove FloatingActionButton's dependency on the ThemeData accentIconTheme and accentTextTheme properties. Apps can configure the appearance of FloatingActionButtons using the theme's FloatingActionButtonTheme instead.
Step 1 of this change was #48435.
Context
This is a small part of the "Update Material Theme System" project, flutter.dev/go/material-theme-system-updates.
Currently, the ThemeData accentIconTheme property is only used by FloatingActionButton. It's the default color of the text or icons that appear within the button.
FloatingActionButton also uses ThemeData accentTextTheme property, however this dependency is undocumented and unnecessary.
Both of these dependencies are apt to be confusing. For example if one configures the Theme's accentIconTheme to change the appearance of floating action buttons, it's difficult to know what other components will be affected. Or might be affected in the future.
The Material Design spec no longer includes an "accent" color. The ColorScheme's secondary color is now used instead.
Currently applications can configure the color of text and icons within FloatingActionButtons with the widget's foregroundColor property or with the FloatingActionButtonTheme's foregroundColor. If neither foregroundColor property is specified the foreground color currently defaults to the accentIconTheme's color. This PR will cause the default to be the color scheme's onSecondary color instead.
Description of change
Currently the accentIconTheme provides a default for the FloatingActionButton's foregroundColor property:
Apps that currently configure their theme's accentIconTheme to effectively configure the foregroundColor of all floating action buttons, can get the same effect by configuring the foregroundColor of their theme's floatingActionButtonTheme. This PR removes the line that contains accentIconTheme.
The FloatingActionButton's foregroundColor is used to configure the textStyle of the RawMaterialButton created by FloatingActionButton. Currently, this text style is based on the button style of ThemeData.accentTextTheme:
Except in a case where an app has explicitly configured the accentTextTheme to take advantage of this undocumented dependency, this use of accentTextTheme is unnecessary. This PR replaces this use of accentTextTheme with textTheme.
Migration guide
To configure the FloatingActionButton's foregroundColor for all FABs, apps can configure the theme's floatingActionButtonTheme instead of its accentIconTheme.
Before
After