Skip to content

Conversation

@kevmoo
Copy link
Contributor

@kevmoo kevmoo commented Jun 13, 2025

This aligns the docs with the changes in
flutter/flutter#170000

This aligns the docs with the changes in
flutter/flutter#170000
@flutter-website-bot
Copy link
Collaborator

flutter-website-bot commented Jun 13, 2025

Visit the preview URL for this PR (updated for commit 447b04a):

https://flutter-docs-prod--pr12125-material-colors-docs-pr1700-sdfkve8o.web.app

Copy link
Contributor

@sfshaza2 sfshaza2 left a comment

Choose a reason for hiding this comment

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

A few nits. :)

@Piinks
Copy link
Contributor

Piinks commented Sep 15, 2025

Greetings from stale PR triage! 👋
This is dependent on flutter/flutter#170000. Are these changes still on your radar?

@sfshaza2
Copy link
Contributor

Pinged kevmoo. He said he'll sync with Kate in the next week.

@sfshaza2 sfshaza2 added the review.await-update Awaiting Updates after Edits label Sep 25, 2025
@kevmoo
Copy link
Contributor Author

kevmoo commented Nov 14, 2025

@Piinks is going to review the target flutter PR. When that lands I'll update this!

github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Nov 21, 2025
This updates Flutter to the latest release, which includes a bunch of
code cleanup that should improve compiled code size and (hopefully)
runtime performance.

The changes in #153385 (discussed
in
https://docs.flutter.dev/release/breaking-changes/material-design-3-token-update)
seem to have been incomplete.

This PR effectively catches up with these changes by updating the "math"
behind primary, secondary, tertiary, error colors.

There is a pending PR on the site to update the corresponding docs:
flutter/website#12125

Fixes #177285
@kevmoo kevmoo marked this pull request as ready for review November 21, 2025 21:36
@kevmoo kevmoo requested a review from a team as a code owner November 21, 2025 21:36
@kevmoo
Copy link
Contributor Author

kevmoo commented Nov 21, 2025

@sfshaza2 – this is ready!

Do we have a process for going back through these and updating after a release?

@kevmoo kevmoo added a.rn.breaking-changes Relates to breaking changes on a Flutter release and removed review.await-update Awaiting Updates after Edits labels Nov 21, 2025
rydmike added a commit to rydmike/flex_seed_scheme that referenced this pull request Nov 22, 2025
## 4.0.0

**Nov 22, 2025**

The version requires Flutter 3.38.0 or higher.

This release **really** brings the bundled forked version of the package [Material Color Utilities (MCU)](https://pub.dev/packages/material_color_utilities) to parity with version 0.13.0. Flutter stable 3.38.x still uses MCU 0.11.1. Next version of Flutter, after stable 0.38, will use MCU 0.13.0, see [PR 12125](flutter/website#12125).

This FSS release contains a breaking change to match the default for expressive on-container colors in MCU 0.12.0. This is also included in the coming bump to MCU 0.13.0 in Flutter after version 3.38.

**BREAKING**
- The `SeedColorScheme.fromSeeds` parameter `useExpressiveOnContainerColors` now defaults to `true` instead of `false`.
  - This makes the default behavior of `SeedColorScheme.fromSeeds` match the default behavior of MCU 0.12.0 and later, where expressive on-container colors are used by default in light mode.
  - If you want to maintain the previous behavior, you can explicitly set `useExpressiveOnContainerColors` to `false` when calling `SeedColorScheme.fromSeeds`.
  - For more information see https://pub.dev/packages/flex_seed_scheme#expressive-on-container-colors
- The `DynamicScheme` parameter `customErrorPalette` was renamed to `errorPalette` to match newly exposed MCU 0.13.0 naming.
  - Previously MCU did not expose this parameter, it was named customErrorPalette in the FSS fork. Now that MCU exposes it, we rename it to match MCU's naming.
  - This is a **minor breaking** change, you will **only** hit it if you have used named parameter `customErrorPalette` in `DynamicScheme`. It is very unlikely to be used directly by end users of this package, as it is a very low-level API and not used by recommended main public APIs directly, but it was a public API, unfortunately.
  - **FlexColorScheme** and **Themes Playground** did not and do not use this API directly, only indirectly via FSS higher APIs.
- **Removed** already in **version 2.0.0** deprecated **private** `int` properties in `FlexSeedScheme._()` and same named **public** `Color` parameters in `SeedColorScheme.fromSeeds()`:
  - `background`
  - `onBackground`
  - `surfaceVariant`
- Removed already in **version 2.0.0** deprecated **public** `int` properties in `FlexTones()`, `FlexTones.light()` and `FlexTones.dark()` and same named parameters in `FlexTones.copyWith()`:
    - `backgroundTone`
    - `onBackgroundTone`
    - `surfaceVariantTone`

**CHANGE**

- Updated `FlexSchemeVariant` and their `configDetails` descriptions to offer better explanations.
  - As stated in the change policy doc comment for the enum `FlexSchemeVariant`, any changes in the property values `variantName`, `description`, `configDetails`, `icon` and `shade` are not considered breaking changes, only patches.
  - These properties may be used when building UIs that present the different scheme variants. They serve no other purpose. They can also be ignored, you can use the enum values as input to build your own UI for selecting and describing the scheme variants. The values are used in the example app and also in the `FlexColorScheme` package example apps, like the **Themes Playground**.

**CHORE**
- MCU: Use `MathUtils.sanitizeDegreesDouble` for hue calculation in Cam16. (MCU update Nov 19, 2025, not yet in any package version)
- MCU: Added the `KeyColor` algorithm and its binary search optimization that was added in **MCU 0.11.2**. This may improve performance when extracting tonal palettes from seed colors.
- MCU: Optimize ARGB and HCT usage in DynamicScheme.
- MCU: A bunch of internal final statics were made const.
   
**TESTS**
* Add explicit test for ARGB int representation.
* Improved tests for TonalPalettes.
* Updated test for new `useExpressiveOnContainerColors` defaulting to `true`.
* Added loop test for all MCU `DynamicSchemeVariant`s to ensure they can be created without errors, so that same `DynamicScheme` matches results from Flutter's `ColorScheme.fromSeed` using corresponding `DynamicSchemeVariant`. The loop test excludes the variants `DynamicSchemeVariant.fidelity`, `DynamicSchemeVariant.monochrome` and `DynamicSchemeVariant.content` that have their own special tone logic. Previously only the default `DynamicSchemeVariant.tonalSpot` was tested this way. This test helps us verify that our fork of MCU can match the version of MCU that Flutter uses internally. When Flutter stable chnages to use MCU 0.13.0, this test will need to change its flag `useExpressiveOnContainerColors` from `false` to `true`.
@rydmike
Copy link
Contributor

rydmike commented Nov 23, 2025

First off, great that this bump is finally being done! Love it! 😄

@kevmoo as agreed on X/Twitter here is some nit details about the breaking change impact, that you may want to consider, or not 😏

User’s often find seed generated ColorScheme a bit complicated and confusing, and yes the algos are for from trivial.

Overall the existing breaking change info is good, maybe at least consider adding that it only impacts light mode generated color schemes. More complete impact info below.

Impact of update to MCU 0.13.0

  • The expressive on-color breaking change for the tokens used by the default Material-3 ColorScheme in Flutter was released already with Flutter 3.22, where the tones for the light scheme on-colors for the default const token value defined ColorScheme changed as follows:
    • onPrimaryContainer: Primary10 to Primary30
    • onSecondaryContainer: Secondary10 to Secondary30
    • onTertiaryContainer: Tertiary10 to Tertiary30
    • onErrorContainer: Error10 to Error30
  • This change does the same for any seed generated light ColorScheme.
  • It only impacts seed generated ColorScheme results for above colors in light mode when the used dynamicSchemeVariant in ColorScheme.fromSeed is:
    • DynamicSchemeVariant.tonalSpot (the default one)
    • DynamicSchemeVariant.neutral
    • DynamicSchemeVariant.vibrant
    • DynamicSchemeVariant.expressive
    • DynamicSchemeVariant.rainbow
    • DynamicSchemeVariant.fruitSalad
  • When using the following DynamicSchemeVariant in ColorScheme.fromSeed there is no change as they have had their own expressive tone exceptions a long time already:
    • DynamicSchemeVariant.fidelity - has had its own expressive on color tone exception since MCU 0.3.0
    • DynamicSchemeVariant.content - has had its own expressive on color tone exception since MCU 0.3.0
    • DynamicSchemeVariant.monochrome - has had its own on color expressive tone exception since MCU 0.4.0

For the above cases the seed generated ColorScheme results in more color expressive on-container colors in light mode, this is in-line with Material expressive color specification.

The new color combinations have a bit less contrast. The accepted min contrast curve is now ContrastCurve(3, 4.5, 7, 11) instead of ContrastCurve(4.5, 7, 11, 21) for the on-container colors. Meaning normal contrast of 4.5 is now accepted, when it was 7 before. The container color and its on-colors appear more colorful, but also loose a bit of contrast.

Visual demonstration

Visually the changes using Color(0xFF6750A4) and the default DynamicSchemeVariant.tonalSpot

   final ColorScheme schemeLight = ColorScheme.fromSeed(
      brightness: Brightness.light,
      seedColor: Color(0xFF6750A4),
      dynamicSchemeVariant: DynamicSchemeVariant.tonalSpot,
    );

Look like this:

Before

Screenshot 2025-11-23 at 2 07 13

After

Screenshot 2025-11-23 at 2 09 48

It is worth noticing that the generated tonal palettes do not change, only the used tones from them. Visually even though only the on-colors for primaryContainer, secondaryContainer, tertiaryContainer and onErrorContainer change, we perceive that the container colors themselves look and feel more colorful "expressive", when they use more colorful text and icons.

The above images where generated with https://rydmike.com/flexseedscheme/demo-v4/

Using the old tones?

There is way when using ColorScheme.fromSeed to get the old on-color tones back after this change.

For those that require them, for backwards compatibility or for contrast reasons, you can set colors back to previously computed seed values manually with overrides in ColorScheme.fromSeed.

Alternatively, with the 3rd party package https://pub.dev/packages/flex_seed_scheme you can seed and opt-out of this change. With on SeedColorScheme.fromSeeds you can seed as follows to opt-out of this change and get the legacy on-color tones:

   final ColorScheme schemeLight = SeedColorScheme.fromSeeds(
      brightness: Brightness.light,
      primaryKey: Color(0xFF6750A4),
      variant: FlexSchemeVariant.tonalSpot,
      useExpressiveOnContainerColors: false, // Opt out of new expressive on color tones
    );

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

Labels

a.rn.breaking-changes Relates to breaking changes on a Flutter release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants