resolve static method

FontWeight? resolve(
  1. BuildContext context,
  2. dynamic value
)

Resolves font weight from string token or FontWeight to FontWeight

Implementation

static FontWeight? resolve(BuildContext context, dynamic value) {
  if (value == null) return null;

  // If it's already a FontWeight, return it directly
  if (value is FontWeight) {
    return value;
  }

  // Otherwise, resolve as string token
  if (value is String) {
    try {
      final fontWeights = FlyTheme.of(context).fontWeight;
      return fontWeights[value];
    } catch (e) {
      throw ArgumentError('Failed to resolve font weight "$value": $e');
    }
  }

  throw ArgumentError(
    'Font weight must be a String or FontWeight, got ${value.runtimeType}',
  );
}