int.tryParse(str)

signature
int.tryParse(s: str, base?: int) -> int | null

Try to parse an integer from a string. The base can be specified as a second argument. If no base is provided, base 10 is used. If the string is not a valid integer, `null` is returned.