Skip to content

Commit 35085c3

Browse files
authored
Improve documentation for ColorSheme.fromImageProvider (#129952)
Sample code is added, documentation condensed, and links to guidelines updated. For b/258360306
1 parent a2dbd1e commit 35085c3

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

packages/flutter/lib/src/material/color_scheme.dart

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -898,29 +898,37 @@ class ColorScheme with Diagnosticable {
898898
/// Generate a [ColorScheme] derived from the given `imageProvider`.
899899
///
900900
/// Material Color Utilities extracts the dominant color from the
901-
/// supplied [ImageProvider]. Using this color, a set of tonal palettes are
902-
/// constructed. These tonal palettes are based on the Material 3 Color
903-
/// system and provide all the needed colors for a [ColorScheme]. These
904-
/// colors are designed to work well together and meet contrast
905-
/// requirements for accessibility.
901+
/// supplied [ImageProvider]. Using this color, a [ColorScheme] is generated
902+
/// with harmnonious colors that meet contrast requirements for accessibility.
906903
///
907904
/// If any of the optional color parameters are non-null, they will be
908905
/// used in place of the generated colors for that field in the resulting
909-
/// color scheme. This allows apps to override specific colors for their
906+
/// [ColorScheme]. This allows apps to override specific colors for their
910907
/// needs.
911908
///
912909
/// Given the nature of the algorithm, the most dominant color of the
913-
/// `imageProvider` may not wind up as one of the ColorScheme colors.
910+
/// `imageProvider` may not wind up as one of the [ColorScheme] colors.
914911
///
915912
/// The provided image will be scaled down to a maximum size of 112x112 pixels
916913
/// during color extraction.
917914
///
915+
/// {@tool dartpad}
916+
/// This sample shows how to use [ColorScheme.fromImageProvider] to create
917+
/// content-based dynamic color schemes.
918+
///
919+
/// ** See code in examples/api/lib/material/color_scheme/dynamic_content_color.0.dart **
920+
/// {@end-tool}
921+
///
918922
/// See also:
919923
///
924+
/// * [M3 Guidelines: Dynamic color from content](https://m3.material.io/styles/color/dynamic-color/user-generated-color#8af550b9-a19e-4e9f-bb0a-7f611fed5d0f)
925+
/// * <https://pub.dev/packages/dynamic_color>, a package to create
926+
/// [ColorScheme]s based on a platform's implementation of dynamic color.
920927
/// * <https://m3.material.io/styles/color/the-color-system/color-roles>, the
921928
/// Material 3 Color system specification.
922929
/// * <https://pub.dev/packages/material_color_utilities>, the package
923-
/// used to generate the base color and tonal palettes needed for the scheme.
930+
/// used to algorightmically determine the dominant color and to generate
931+
/// the [ColorScheme].
924932
static Future<ColorScheme> fromImageProvider({
925933
required ImageProvider provider,
926934
Brightness brightness = Brightness.light,

0 commit comments

Comments
 (0)