get<T> method

T? get<T>(
  1. HeadlessFeatureKey<T> key
)

Gets the value for a typed feature key.

Returns null if the key is not present. In debug mode, asserts if the value type doesn't match the key type.

Implementation

T? get<T>(HeadlessFeatureKey<T> key) {
  final value = _values[key.id];
  if (value == null) return null;
  assert(
    value is T,
    'HeadlessItemFeatures: key $key expects $T but got ${value.runtimeType}',
  );
  return value as T;
}