getPropsInt function

int getPropsInt(
  1. Map<String, dynamic> props,
  2. String key, [
  3. int defaultValue = 0
])

Extracts an int value from props.

Handles both int and String representations.

Implementation

int getPropsInt(
  Map<String, dynamic> props,
  String key, [
  int defaultValue = 0,
]) {
  final value = props[key];
  if (value is int) return value;
  if (value is String) return int.tryParse(value) ?? defaultValue;
  if (value is double) return value.toInt();
  return defaultValue;
}