getHeader method

String? getHeader(
  1. String headerConstant
)

Gets a specific header from CDN config using constant identifiers

Implementation

String? getHeader(String headerConstant) {
  _ensureInitialized();
  try {
    final cachedConfig = getCDNConfig();

    // Use the constant to get the property name, then look up the value
    if (cachedConfig?.apiHeaders?[headerConstant] != null) {
      final value = cachedConfig!.apiHeaders![headerConstant];
      return value;
    }

    // Fallback to default config using the same property name
    final defaultValue = (_bundledConfig['api']?['headers'] as Map<String, dynamic>?)?[headerConstant] as String?;
    return defaultValue;
  } catch (e) {
    return (_bundledConfig['api']?['headers'] as Map<String, dynamic>?)?[headerConstant] as String?;
  }
}