colorFromHexString static method
从16进制数字字符串,生成Color,例如EDF0F3
Implementation
static Color colorFromHexString(String? s) {
if (s == null || s.length != 6 || int.tryParse(s, radix: 16) == null) {
return Colors.black;
}
return Color(int.parse(s, radix: 16) + 0xFF000000);
}