asIntSafe method

int? asIntSafe([
  1. int? fallback
])

Safely converts this string to an integer

fallback The value to return if conversion fails (defaults to null)

Returns the parsed integer or fallback if conversion fails

Example:

print('42'.asIntSafe()); // 42
print('invalid'.asIntSafe(0)); // 0
print('invalid'.asIntSafe()); // null

Implementation

int? asIntSafe([int? fallback]) {
  return QTypeConversion.toIntSafe(this, fallback);
}