toInt function

int? toInt(
  1. String str, {
  2. int? radix,
})

Converts the string to an integer.

Returns null if the string cannot be parsed. An optional radix between 2 and 36 may be supplied.

Example:

toInt('42'); // 42
toInt('ff', radix: 16); // 255
toInt('abc'); // null

Implementation

int? toInt(String str, {int? radix}) => int.tryParse(str.trim(), radix: radix);