isIntList function

bool isIntList(
  1. Object? value, [
  2. String delimiter = ','
])

Returns true if is a list of int. Can be a string of int too.

Implementation

bool isIntList(Object? value, [String delimiter = ',']) {
  if (value == null) return false;

  if (value is List<int>) return true;

  if (value is Iterable) {
    return listMatchesAll(value, (e) => e is int);
  }

  var s = value.toString();
  return RegExp(r'^-?\d+(?:' + delimiter + r'-?\d+)+$').hasMatch(s);
}