Skip to content

Instantly share code, notes, and snippets.

@sudeshim3
Last active September 24, 2019 02:53
Show Gist options
  • Save sudeshim3/7137e84a78d1f28e32d7849020b6b05a to your computer and use it in GitHub Desktop.
Save sudeshim3/7137e84a78d1f28e32d7849020b6b05a to your computer and use it in GitHub Desktop.
class HexColor extends Color {
static int _getColorFromHex(String hexColor) {
hexColor = hexColor.toUpperCase().replaceAll("#", "");
if (hexColor.length == 6) {
hexColor = "FF" + hexColor;
}
return int.parse(hexColor, radix: 16);
}
HexColor(final String hexColor) : super(_getColorFromHex(hexColor));
}
//Link for formula to convert hex to normal hex color
//https://stackoverflow.com/questions/15852122/hex-transparency-in-colors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment