Skip to content
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

Clarify the IconTheme documentation #83677

Merged
merged 1 commit into from Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/flutter/lib/src/widgets/icon.dart
Expand Up @@ -100,21 +100,22 @@ class Icon extends StatelessWidget {
///
/// Defaults to the current [IconTheme] color, if any.
///
/// The given color will be adjusted by the opacity of the current
/// The color (whether specified explicitly here or obtained from the
/// [IconTheme]) will be further adjusted by the opacity of the current
/// [IconTheme], if any.
///
///
/// In material apps, if there is a [Theme] without any [IconTheme]s
/// specified, icon colors default to white if the theme is dark
/// and black if the theme is light.
///
/// If no [IconTheme] and no [Theme] is specified, icons will default to black.
/// If no [IconTheme] and no [Theme] is specified, icons will default to
/// black.
///
/// See [Theme] to set the current theme and [ThemeData.brightness]
/// for setting the current theme's brightness.
///
/// {@tool snippet}
/// Typically, a material design color will be used, as follows:
/// Typically, a Material Design color will be used, as follows:
///
/// ```dart
/// Icon(
Expand Down
13 changes: 11 additions & 2 deletions packages/flutter/lib/src/widgets/icon_theme.dart
Expand Up @@ -49,9 +49,18 @@ class IconTheme extends InheritedTheme {
final IconThemeData data;

/// The data from the closest instance of this class that encloses the given
/// context.
/// context, if any.
///
/// Defaults to the current [ThemeData.iconTheme].
/// If there is no ambient icon theme, defaults to [IconThemeData.fallback].
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe @HansMuller had plans to eventually stop using fallback for this kind of thing. That said we should document how it currently works, so this is a nice clarification.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I was referring to ThemeData.fallback(). This looks like a helpful clarification.

/// The returned [IconThemeData] is concrete (all values are non-null; see
/// [IconThemeData.isConcrete]). Any properties on the ambient icon theme that
/// are null get defaulted to the values specified on
/// [IconThemeData.fallback].
///
/// The [Theme] widget from the `material` library introduces an [IconTheme]
/// widget set to the [ThemeData.iconTheme], so in a Material Design
/// application, this will typically default to the icon theme from the
/// ambient [Theme].
///
/// Typical usage is as follows:
///
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/widgets/image_icon.dart
Expand Up @@ -51,7 +51,7 @@ class ImageIcon extends StatelessWidget {
/// Defaults to the current [IconTheme] color, if any. If there is
/// no [IconTheme], then it defaults to not recolorizing the image.
///
/// The image will additionally be adjusted by the opacity of the current
/// The image will be additionally adjusted by the opacity of the current
/// [IconTheme], if any.
final Color? color;

Expand Down