isDoubleList function

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

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

Implementation

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

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

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

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