Enhance ColorScheme.fromSeed with a new variant parameter (#144805)

Fixes #144649

This PR is to add an enhancement for `ColorScheme.fromSeed()`.  When we input a brighter color with a high chroma and we want the resulting `ColorScheme` respects the source color, we can achieve this by setting

```dart
ColorScheme.fromSeed(
  seedColor: sourceColor,
  variant: Variant.fidelity,
  ...
)
```

Here is a demo for `ColorScheme` constructed by all 9 variants:
![Screenshot 2024-03-13 at 4 33 02 PM](https://github.com/flutter/flutter/assets/36861262/2cdbe559-67ff-4f8b-bd48-ccff5131b949)
![Screenshot 2024-03-13 at 4 33 07 PM](https://github.com/flutter/flutter/assets/36861262/e6af2362-c501-499b-8880-06a321de91e6)
This commit is contained in:
Ian Hickson
2024-04-03 08:54:34 -07:00
committed by GitHub
parent a46ed4ee07
commit 950ec1c405
4 changed files with 348 additions and 100 deletions

View File

@@ -11,10 +11,9 @@ void main() {
await tester.pumpWidget(
const example.ColorSchemeExample(),
);
expect(find.text('Light ColorScheme'), findsOneWidget);
expect(find.text('Dark ColorScheme'), findsOneWidget);
expect(find.text('tonalSpot (Default)'), findsOneWidget);
expect(find.byType(example.ColorChip), findsNWidgets(86));
expect(find.byType(example.ColorChip), findsNWidgets(43 * 9));
});
testWidgets('Change color seed', (WidgetTester tester) async {
@@ -30,7 +29,7 @@ void main() {
)
);
}
expect(coloredBox().color, const Color(0xFF6750A4));
expect(coloredBox().color, const Color(0xff65558f));
await tester.tap(find.byType(MenuAnchor));
await tester.pumpAndSettle();
await tester.tap(find.widgetWithText(MenuItemButton, 'Yellow'));