getPropsValue<T> function

T getPropsValue<T>(
  1. Map<String, dynamic> props,
  2. String key,
  3. T defaultValue
)

Type-safe props helper for extracting values from decoded props.

Example

final props = decodeProps(prop('data'));
final name = getPropsValue<String>(props, 'name', 'Unknown');
final count = getPropsValue<int>(props, 'count', 0);

Implementation

T getPropsValue<T>(Map<String, dynamic> props, String key, T defaultValue) {
  final value = props[key];
  if (value is T) return value;
  return defaultValue;
}