fix: avoid hex color parse error

This commit is contained in:
Rongjian Zhang
2020-10-29 21:02:45 +08:00
parent d9ca01b99d
commit 5f45a54f95

View File

@@ -48,7 +48,7 @@ Color convertColor(String cssHex) {
if (cssHex.length == 3) {
cssHex = cssHex.split('').map((char) => char + char).join('');
}
return Color(int.parse('ff' + cssHex, radix: 16));
return Color(int.tryParse('ff' + cssHex, radix: 16) ?? 0);
}
Color getFontColorByBrightness(Color color) {