getAssetType method

String getAssetType(
  1. AssetXConfig config
)

Determines asset type based on config

Implementation

String getAssetType(AssetXConfig config) {
  final ext = extension;

  // Check config type registry first
  if (config.typeRegistry != null) {
    for (final entry in config.typeRegistry!.entries) {
      final typeName = entry.key;
      final typeConfig = entry.value;

      // Check file extensions
      if (typeConfig.fileExtensions != null &&
          typeConfig.fileExtensions!.contains(ext)) {
        return _getImplementationForType(typeName, config);
      }

      // Check patterns
      if (typeConfig.pattern != null) {
        for (final pattern in typeConfig.pattern!) {
          if (_matchesPattern(normalizedPath, pattern)) {
            return _getImplementationForType(typeName, config);
          }
        }
      }
    }
  }

  // Fall back to defaults
  return _getImplementationForType(_getDefaultTypeName(ext), config);
}