stringToColor function

Color? stringToColor(
  1. String data
)

Implementation

Color? stringToColor(String data) {
  if (data.startsWith('Color(0x')) {
    return Color(int.parse(data.split('0x')[1].split(')')[0], radix: 16));
  } else if (data.startsWith('ColorSwatch')) {
    return stringToColor(data.split('primary value: ')[1]);
  }

  return null;
}