toIntN static method

int? toIntN(
  1. dynamic d
)

Converts a dynamic value to a nullable integer.

d - The dynamic value to be converted. Returns an integer if the conversion is successful, otherwise null.

Implementation

static int? toIntN(dynamic d) {
  if (d is int) {
    return d;
  }
  if (d is double) {
    return d.toInt();
  }
  if (d is String) {
    return int.tryParse(d);
  }
  return null;
}