-
Hi @rydmike , I noticed some color differences between flutter defaults and flex_color_scheme using material3 on TimePicker. Code Sample:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hi @sabin26, thanks for your question. To get the same result in FCS, you also need to use the same seed color key generation algorithm in FCS that the The API using There are two ways to get the same result: 1. Use same input colorsSchemeYou can use a pre-generated ColorScheme's with FlexColorScheme as well, you then just pass in the same static ThemeData getThemeData(final int color, {final bool isDark = false}) {
switch (isDark) {
case false:
return FlexThemeData.light(
colorScheme: colorScheme: ColorScheme.fromSeed(seedColor: Color(AppColors.primary)),
useMaterial3: true,
subThemesData: const FlexSubThemesData(),
visualDensity: FlexColorScheme.comfortablePlatformDensity,
);
default:
return FlexThemeData.dark(
colorScheme: colorScheme: ColorScheme.fromSeed(seedColor: Color(AppColors.primary), brightness: Brightness.dark),
useMaterial3: true,
subThemesData: const FlexSubThemesData(),
visualDensity: FlexColorScheme.comfortablePlatformDensity,
);
}
It is also possible to use the 2. Use
|
Beta Was this translation helpful? Give feedback.
-
I am using the beta channel of flutter and I tested the first option i.e. using colorScheme and the results are correct (as expected). I was not aware that FlexSchemeColor.from is an older API. Thank you for your help ! |
Beta Was this translation helpful? Give feedback.
-
Yes, a bit older, but perfectly usable, but most importantly different. It predates It is a bit more related to Like Flutter itself, FCS is beginning to also contain legacy APIs, but in contradiction to many of those in Flutter they are still useful, depends on your design goals. In Flutter the I have a chapter in the FCS docs that talks about different ways to define colors for Using a full You can still use it as input and add additional surface blends, etc, then of course those surface colors in the ColorScheme will be overridden. You can even use it as input to generate ColorScheme in FCS, using the primary/secondary/tertiary colors in the ColorScheme as seed color suing another algo than the default one in Flutter. I know, lot's of flexibility, so it can be a bit confusing. Future work, but then also breaking version, will focus on making things even simpler and clearer. I am converting this to a FAQ question. It is a good and valid question, that others might stumble upon in discussions then later as well. |
Beta Was this translation helpful? Give feedback.
Hi @sabin26, thanks for your question.
To get the same result in FCS, you also need to use the same seed color key generation algorithm in FCS that the
ColorScheme.fromSeed(seedColor: Color(AppColors.primary)),
uses in your example.The API using
FlexSchemeColor.from(primary: Color(color)),
is an older API that uses FCS internal algorithm to generate colors from only a few colors. It was used before Flutter even had aColorScheme.fromSeed
algorithm. It can still be used, it is based on similar ideas, that Flutter added later but it produced different results.There are two ways to get the same result:
1. Use same input colorsScheme
You can use a pre-generated ColorScheme's with FlexColorS…