colorTW function

Color? colorTW(
  1. List<String> params
)

Implementation

Color? colorTW(List<String> params) {
  for (var element in params.reversed) {
    // Color name has to start with 'text-'
    if (!element.startsWith('text-')) {
      continue;
    }

    // The input color string
    String input = element.replaceFirst('text-', '');

    // If the color name is not in the tailwindColors map, continue
    String colorName = input.split('-').first;
    if (!orkittSafeColors.containsKey(colorName)) {
      continue;
    }

    // Return if the color is not a shade
    if (!input.contains('-')) {
      return ThemeColorExtract.fromHex(orkittSafeColors[colorName]);
    }

    // Return color with shade
    int colorShade = int.parse(input.split('-').last);
    return ThemeColorExtract.fromHex(orkittSafeColors[colorName][colorShade]);
  }

  return null;
}