$int static method

int? $int(
  1. dynamic json,
  2. String key
)

Implementation

static int? $int(dynamic json, String key) {
  final value = _getJsonValue(json, key);
  if (value == null) return null;
  if (value is int) return value;
  if (value is String) {
    final v = num.tryParse(value);
    return v?.toInt();
  }
  if (value is double) return value.toInt();
  return int.tryParse(value.toString());
}