toInteger method

int? toInteger()

Implementation

int? toInteger() {
  final self = this;
  if (self == null) return 0;
  if (self is int) return self;
  if (self is num) return self.toInt();
  if (self is String) return self.isBlank ? 0 : self.toInt();
  assert(false, "Can't convert to int");
  return null;
}