resolveColor static method

Color resolveColor(
  1. dynamic value,
  2. BuildContext context,
  3. FlyToken<Color> tokens
)

Resolves color values (Color, string tokens, hex)

Implementation

static Color resolveColor(
  dynamic value,
  BuildContext context,
  FlyToken<Color> tokens,
) {
  if (value is Color) return value;

  if (value is String) {
    // Try token lookup first
    final tokenValue = tokens[value];
    if (tokenValue != null) return tokenValue;

    // Then try hex parsing
    return _parseColor(value, context);
  }

  final availableTokens = tokens.keys.take(5).join(', ');
  throw ArgumentError(
    'Cannot resolve color value "$value": expected Color object, hex string (#RRGGBB), or token name. Available tokens: $availableTokens${tokens.keys.length > 5 ? '...' : ''}',
  );
}