Converts value to an int if possible, otherwise returns null.
value
int? intOrNull(dynamic value) { if (value == null) return null; if (value is int) return value; return int.tryParse(value.toString()); }