isBoolList function

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

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

Implementation

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

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

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

  var s = value.toString().toLowerCase();
  return RegExp(r'^(?:true|false|yes|no)(?:' +
          delimiter +
          r'(?:true|false|yes|no))+$')
      .hasMatch(s);
}