Closed MahanRahmati closed 4 months ago
We need to bump material_color_utilities, and it is an SDK dependency.
new colors doesn't seem to be added in Scheme
and they apparently moved to DynamicScheme
as Scheme
is deprecated (see this)
this package seem to direct take CorePalette
from android. I tried to make following changes locally according to their migration guide
// corepalette_to_colorscheme.dart
final SchemeTonalSpot scheme;
switch (brightness) {
case Brightness.light:
scheme = SchemeTonalSpot(
sourceColorHct: Hct.fromInt(primary.keyColor.toInt()),
isDark: false,
contrastLevel: 0.0);
break;
case Brightness.dark:
scheme = SchemeTonalSpot(
sourceColorHct: Hct.fromInt(primary.keyColor.toInt()),
isDark: true,
contrastLevel: 0.0);
break;
}
...
return ColorScheme(
primary: Color(MaterialDynamicColors.primary.getArgb(scheme)),
onPrimary: Color(MaterialDynamicColors.onPrimary.getArgb(scheme)),
...
but the unit test fails
dynamic_color: Core palette detected.
══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following TestFailure was thrown running a test:
Expected: Color:<Color(0xff286c2a)>
Actual: Color:<Color(0xff8c4a60)>
for reference I used code from ColorScheme.fromSeed()
from Flutter SDK
@boredcodebyk
but the unit test fails
dynamic_color: Core palette detected. ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════ The following TestFailure was thrown running a test: Expected: Color:<Color(0xff286c2a)> Actual: Color:<Color(0xff8c4a60)>
for reference I used code from
ColorScheme.fromSeed()
from Flutter SDK
Shouldn't just correcting expecting colors in test file enough if everything else works perfectly? (not based on this error but checking what's the real output of given colorscheme in test on md3 colorscheme generator, as colorscheme colors changed, now we need to change test file too)
@andr202 you have a valid point but theoretical the test doesn't needs to be changed. in the test file a container is given primary color and tested with the expected color which passes. in this case, the primary color gets way off from expected color for some reason. I'm still looking into it (and now I'm clueless)
Is there still any goals to be met with this PR? The merge request is very waited due to the changes on 3.22
Hi @MahanRahmati, how do I use this branch? It seems to fail as the new properties do not exist in the Scheme class in material_color_utilities. https://github.com/material-foundation/material-color-utilities/blob/main/dart/lib/scheme/scheme.dart
Hi @MahanRahmati, how do I use this branch? It seems to fail as the new properties do not exist in the Scheme class in material_color_utilities. https://github.com/material-foundation/material-color-utilities/blob/main/dart/lib/scheme/scheme.dart
You can't use it yet. The branch is broken. I'm waiting for flutter to bump material_color_utilities and update the branch later.
This is quite urgent, has flutter bumped that yet?
Closing as the approach here will necessitate something like https://github.com/material-foundation/flutter-packages/compare/main...hasali19:material-foundation-flutter-packages:main (with fixes as the color mappings aren't accurate) to construct the color scheme
Description
Add new material colors introduced in Flutter 3.22.
Issues
Fixes #582
Checklist
CHANGELOG.md