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

Add content-based colorScheme functionality #122919

Merged
merged 40 commits into from Mar 19, 2023

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. team Infra upgrades, team productivity, code health, technical debt. See also team: labels. labels Mar 17, 2023
esouthren added 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 added 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).

packages/flutter/lib/src/material/color_scheme.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/color_scheme.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/color_scheme.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/color_scheme.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/color_scheme.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/color_scheme.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/color_scheme.dart Outdated Show resolved Hide resolved
packages/flutter/lib/src/material/color_scheme.dart Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. team Infra upgrades, team productivity, code health, technical debt. See also team: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for creating ColorSchemes from content
2 participants