convertNumber function
Converts a number or a string representation of a number into an int.
Returns null if the input cannot be converted.
Implementation
int? convertNumber(Object? arg) {
if (arg is int) return arg;
if (arg is String && arg.isNotEmpty) return int.tryParse(arg);
return null;
}