toInt method

int toInt({
  1. int def = 0,
})

Try to parse to int, fallback to def

Implementation

int toInt({int def = 0}) {
  if (this == null) return def;
  return int.tryParse(toString()) ?? def;
}