isNumber property

bool isNumber

Determine whether the current instance is an int or double.

Can be called in the following ways, 2.isNumber 2.0.runtimeType.isNumber

Implementation

bool get isNumber {
  if (this is Type) {
    return this == double || this == int;
  } else {
    return this is num;
  }
}