parseColor method
Implementation
Color parseColor(String style) {
final split = style.split("-");
if (split.length == 2) {
try {
final stringColor = split[1];
if (stringColor == "white") {
return Colors.white;
} else if (stringColor == "black") {
return Colors.black;
} else if (colorHelper.isValidColor(stringColor)) {
return colorHelper.fromString(stringColor) ?? Colors.transparent;
} else if (stringColor == "transparent") {
return Colors.transparent;
}
} on RangeError catch (_) {}
} else if (split.length == 3) {
try {
final stringColor = split[1];
final colorValue = split[2];
if (colorHelper.isValidColor(stringColor)) {
return colorHelper.fromMaterialColor(
colorHelper.fromString(stringColor),
colorValue,
);
}
} on RangeError catch (_) {}
}
return Colors.transparent;
}