Last active
December 19, 2021 21:02
-
-
Save Roaa94/5bc7b6cc1343727c4adfab9381f8cca3 to your computer and use it in GitHub Desktop.
App Colors helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppColors { | |
static List<Color> primaryColors = const [ | |
Color(0xffd23156), | |
Color(0xff16b9fd), | |
Color(0xff13d0c1), | |
Color(0xffe5672f), | |
Color(0xffb73d99), | |
]; | |
static Color getShade(Color color, {bool darker = false, double value = .1}) { | |
assert(value >= 0 && value <= 1); | |
final hsl = HSLColor.fromColor(color); | |
final hslDark = hsl.withLightness((darker ? (hsl.lightness - value) : (hsl.lightness + value)).clamp(0.0, 1.0)); | |
return hslDark.toColor(); | |
} | |
static MaterialColor getMaterialColorFromColor(Color color) { | |
Map<int, Color> _colorShades = { | |
50: getShade(color, value: 0.5), | |
100: getShade(color, value: 0.4), | |
200: getShade(color, value: 0.3), | |
300: getShade(color, value: 0.2), | |
400: getShade(color, value: 0.1), | |
500: color, | |
600: getShade(color, value: 0.1, darker: true), | |
700: getShade(color, value: 0.15, darker: true), | |
800: getShade(color, value: 0.2, darker: true), | |
900: getShade(color, value: 0.25, darker: true), | |
}; | |
return MaterialColor(color.value, _colorShades); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment