getColorFromString function

Color? getColorFromString(
  1. String? color
)

Implementation

Color? getColorFromString(String? color) {
  try {
    if (color == null) {
      return null;
    }
    if (color.startsWith("0xFF")) {
      color = color.replaceAll("0xFF", "#");
    }
    if (color.startsWith("#"))
      return getColorFromHEX(color);
    else if (color.contains("rgb")) {
      return getColorFromRGBString(color);
    } else {
      return getColorFromName(color);
    }
  } catch (e) {
    return null;
  }
}