Color myColor = Color(0xff123456)
// where 123456 is your hex color code and
// 0xff is the opacity value and can be changed.
Color c = const Color(0xFF42A5F5);
Color c = const Color.fromARGB(0xFF, 0x42, 0xA5, 0xF5);
Color c = const Color.fromARGB(255, 66, 165, 245);
Color c = const Color.fromRGBO(66, 165, 245, 1.0);
const color = const Color(0xffb74093); // Second `const` is optional in assignments.
Color getColorFromColorCode(String code){
return Color(int.parse(code.substring(1, 7), radix: 16) + 0xFF000000);
}
Color myHexColor = Color(0xff123456)
// her you notice I use the 0xff and that is opacity or transparency of the color
// and you can also change these value .
// color start from 0xff_colorcode
Color(0xffA5A4A4)
Color(0xffA5A4A4).withOpacity(.5)
const color = const Color(0xffb74093);
// Learn Flutter without leaving VS Code
// Visit sideguide.dev/courses/flutter?ref=g
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));
}
dependencies:
hexcolor: ^2.0.5
const color = const Color(0xFFB74093);
// first 'FF' is opacity