getPalletConstants method

Map<String, dynamic> getPalletConstants(
  1. String palletName
)

Get all constants for a specific pallet

Returns a map of constant name to decoded value

Implementation

Map<String, dynamic> getPalletConstants(String palletName) {
  // Check if we have all constants cached for this pallet
  if (_decodedCache.containsKey(palletName)) {
    final pallet = registry.palletByName(palletName);
    if (pallet != null && _decodedCache[palletName]!.length == pallet.constants.length) {
      return Map.from(_decodedCache[palletName]!);
    }
  }

  final pallet = registry.palletByName(palletName);
  if (pallet == null) {
    throw MetadataException('Pallet $palletName not found');
  }

  final constants = <String, dynamic>{};
  for (final constant in pallet.constants) {
    // Check cache first
    if (_decodedCache.containsKey(palletName) &&
        _decodedCache[palletName]!.containsKey(constant.name)) {
      constants[constant.name] = _decodedCache[palletName]![constant.name];
    } else {
      final decodedValue = _decodeConstant(constant);
      constants[constant.name] = decodedValue;
      _cacheConstant(palletName, constant.name, decodedValue);
    }
  }

  return constants;
}