Skip to content

Add content-based colorScheme functionality#122919

Merged
esouthren merged 40 commits intoflutter:masterfrom
esouthren:dynamic_color
Mar 19, 2023
Merged

Add content-based colorScheme functionality#122919
esouthren merged 40 commits intoflutter:masterfrom
esouthren:dynamic_color

Conversation

@esouthren
Copy link
Contributor

@esouthren esouthren commented Mar 17, 2023

Fixes #119333.

Adds ColorScheme.fromImageProvider() constructor to Material's color scheme.

This allows users to pass an ImageProvider and receive a Material-based color scheme from the dominant colors of the image. By using an ImageProvider, developers can use local assets, network or memory images. We use the Material Color Utilities library to extract and score the dominant colors of the image.

The scheme can be in light or dark mode, and additionally, any property of the scheme can be overridden with custom colors if they are preferred over the generated colors.

An examples/ demo has been added, with a further update to the Material 3 demo app to come.

The example demo looks as follows:

screen.mov

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard bot added d: examples Sample code and demos documentation f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. labels Mar 17, 2023
esouthren pushed a commit to flutter/assets-for-api-docs that referenced this pull request Mar 17, 2023
For flutter/flutter#122919. 

Images are used in the demo for image color extraction to generate color schemes. Images are owned by Google and have unrestricted licensing.
esouthren pushed a commit to flutter/assets-for-api-docs that referenced this pull request Mar 17, 2023
For flutter/flutter#122919. 

Images are used in the demo for image color extraction to generate color schemes. Images are owned by Google and have unrestricted licensing.
@esouthren esouthren marked this pull request as ready for review March 17, 2023 21:38
Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

This looks great. Nearly all of the feedback is trivial formatting stuff (mostly just advocating fewer line breaks).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for creating ColorSchemes from content

2 participants