isNumeric function

bool isNumeric(
  1. String s
)

Whether s consists only of digits (a leading + is allowed).

Implementation

bool isNumeric(String s) {
  final body = s.startsWith('+') ? s.substring(1) : s;
  if (body.isEmpty) return false;
  for (var i = 0; i < body.length; i++) {
    final c = body.codeUnitAt(i);
    if (c < 0x30 || c > 0x39) return false;
  }
  return true;
}